This archived community thread from the APG vNext support forum discusses: Expiration Header to Save Bandwidth.
About This Topic
In APG vNext, I've set up expiration headers for static content for IIS 7+, so you don't have to do anything to save bandwidth and have great client side per...
Getting Help with APG vNext
APG vNext is a powerful ASP.NET forum and community platform. For questions related to this topic:
- Browse the Knowledge Base for documented solutions
- Search the community forum for similar threads
- Check the FAQ for common questions and answers
- Review the Installation and Upgrade guides
If you need direct assistance, the support team is active in the community forum.
Setting Cache Expiration Headers in APG vNext to Save Bandwidth
Configuring HTTP cache expiration headers for APG vNext's static assets (CSS, JavaScript, images, fonts) reduces bandwidth consumption and improves page load speed for returning visitors. Browsers cache assets locally and only re-download them when the cache expires or the asset URL changes (via version parameter).
Setting Static Asset Cache Headers in IIS
<!-- web.config: aggressive caching for static assets -->
<location path="assets">
<system.webServer>
<staticContent>
<clientCache
cacheControlMode="UseMaxAge"
cacheControlMaxAge="365.00:00:00"
cacheControlCustom="public, immutable" />
</staticContent>
</system.webServer>
</location>
immutable tells the browser: "this URL will never serve different content, so don't even check for updates." Use only with versioned URLs.
Cache-Busting with Version Parameter
<!-- In skin template: append version to asset URLs -->
<link rel="stylesheet"
href="/assets/css/main.css?v={APG.Skin.Version}" />
<script src="/assets/js/apg.min.js?v={APG.Skin.Version}"></script>
<!-- web.config: skin version string -->
<add key="APG.Skin.Version" value="5.5.1" />
<!-- Change this value on each deployment to bust the cache -->
Caching Recommendations by Asset Type
- CSS / JS: 1 year with version parameter (immutable)
- Images (logos, banners): 1 year with version parameter
- User-uploaded files (upfiles/): 7-30 days (may be updated or replaced)
- HTML pages: 0 or short (1-5 min via CDN), browser should always revalidate
Measuring Bandwidth Savings from Expiration Headers
After implementing expiration headers, quantify the bandwidth reduction using Cloudflare Analytics or your server access logs. Cloudflare's Cache Analytics dashboard shows the cache hit ratio — the percentage of requests served from cache versus from the origin server. A cache hit ratio below 80% for static assets (CSS, JS, images) indicates that caching is not working as effectively as it should, which may be due to query strings bypassing the cache, vary headers preventing cache sharing, or expiration times being too short. The target cache hit ratio for a well-configured APG vNext installation is 90-95% for static assets. Each percentage point improvement in cache hit ratio reduces origin bandwidth consumption proportionally, which directly reduces hosting costs on bandwidth-billed server plans.
Cache Busting Strategy for Versioned Assets
When APG vNext is upgraded and new CSS or JavaScript files are deployed, browsers with cached versions of the old files may not receive the updates until their cached copies expire. The standard solution is cache busting: appending a version query string (e.g., ?v=5.5.2) to static asset URLs, which causes browsers to treat them as new resources and fetch fresh copies. APG vNext automatically appends a build version query string to all CSS and JS asset URLs in the generated HTML, ensuring that after an upgrade, all members receive the new assets on their next page load regardless of their browser's cache state. The version string is configured by the APG.BuildVersion setting in web.config and should be updated with each release deployment.
Service Worker Caching for APG vNext PWA Mode
For APG vNext installations configured in Progressive Web App mode, the service worker provides an additional caching layer on top of server-side expiration headers. The service worker intercepts all requests from the browser and serves cached responses for static assets without any network round-trip — this is faster than even a CDN cache hit, because the response comes from the device's local storage rather than a remote server. Configure the service worker caching strategy in Admin Panel → PWA → Caching Strategy. The recommended strategy for APG vNext static assets is Cache First with a one-week max age and a background revalidation step on cache hit (stale-while-revalidate pattern). Dynamic content (thread pages, member profiles) should use the Network First strategy so members always see the latest content, with a fallback to the cached version when offline.
Preloading Critical Assets
Use browser resource hints to preload critical CSS and JavaScript assets that are needed for the first page render. APG vNext generates <link rel="preload"> tags for the main CSS file and critical JavaScript modules when the preload setting is enabled. Combined with a long expiration header on these assets, preloading ensures that returning visitors see the forum's first page render in under 200ms even on slow connections, because the assets are both cached locally and preloaded in the browser's memory cache for the current session.
Related Resources
Looking for more help? Browse the support forum or check the Knowledge Base.