Asset File Caching
Asset files such as multimedia files, javascript, and CSS typically are cached by the edge network according to the caching profiles.
Asset file extensions
Browser cache headers on asset URLs
In addition to being cached at the edge, responses served at asset URLs
are sent to visitors with far-future Cache-Control and Expires
headers so that browsers cache them locally. These headers are set by
the edge network based on the URL’s file extension:
- They are applied in every caching profile, including Assets Only.
- They replace any
Cache-Controlheader your application sets on that URL. - They are applied to any response served at an asset URL, including redirects, not just the files themselves.
- Adding the URL as a Non-Cached Path stops edge caching but does not change these headers.
This works well for fingerprinted assets, where the URL changes whenever the content changes. It causes problems for URLs that end in an asset extension but return short-lived responses. The most common case is a framework route that redirects an image URL to a temporary signed storage URL (for example, Rails Active Storage in its default redirect mode). The browser caches the redirect long after the signed URL has expired, and the image breaks.
For those routes, configure your application to serve the file directly instead of redirecting. See the Rails Active Storage article for the recommended configuration, or contact support to have header handling adjusted for your site.
Versioning cache URLs
https://example.com/users/?id=1
https://example.com/users/?id=2