What is Static Content?
Static content is served from a stored representation that ordinarily remains identical across requests. It changes only when the underlying resource is updated, rather than through per-request generation.
How Static Content works
Static content is a delivery property: the server can return bytes that already exist, such as a file on disk or an object in a bucket, without running application logic for the request. The file may have been written by hand, emitted by a build, or exported by a media pipeline, so “static” does not mean it never changes. It means the content changes when the stored file is replaced, not when a request arrives. Two HTTP mechanisms therefore do most of the work. Freshness, set with Cache-Control, tells browsers and CDNs how long they may reuse a copy without asking. Validators, an ETag or a Last-Modified date, let a cache ask whether its copy is still current and receive a 304 response without a body when it is. Images, video segments, fonts, style sheets, scripts, and prebuilt HTML pages are typical static content; a response assembled per request from application state is dynamic content.
Key facts
- 1Is a static file cached automatically? Not reliably, and not for a predictable time. Without explicit freshness from
Cache-ControlorExpires, HTTP lets a cache apply heuristic freshness: RFC 9111 allows it to estimate a lifetime fromLast-Modifiedand gives 10% of the time since the last modification as a typical setting. MDN recommends an explicitCache-Controlheader on every response for that reason. CDNs add defaults of their own. Cloudflare, for example, caches by file extension and not by MIME type, does not cache HTML or JSON by default, and does not cache a response that carriesSet-Cookie. - 2Should a static file keep its URL when its content changes? Decide per file. A file whose URL changes with its content, such as a bundle with a hash in its name, can be served with a long
max-age(MDN’s example uses one year) plusimmutable, because a new version arrives under a new URL. A file that must keep its URL, such as an HTML page, should not get a long lifetime: updating the file on the server does not replace a fresh copy that a browser has already stored, because, as MDN notes, requests for it no longer reach the server, so the browser can keep using that copy until its lifetime expires. A CDN that offers purging can drop its own copy, but a purge does not reach copies already stored in browsers. Serve those files withno-cacheand validators, so that every reuse is checked and an unchanged file costs only a 304. - 3Does serving from a file make a response safe for a shared cache? No. Cacheability follows the request and the response headers, not how the body was produced. RFC 9111 forbids a shared cache from reusing a response to a request that carried
Authorizationunless the response allows it withpublic,s-maxage, ormust-revalidate. It has no such rule for a request that carried aCookieheader, and MDN notes that a cookie alone does not make a response private. The RFC also notes thatSet-Cookiedoes not inhibit caching, so a static file sent with a cookie can be stored and reused for later requests by a cache that follows the standard. A CDN may apply a rule of its own instead: Cloudflare, as noted above, does not cache such a response by default. Prefer not to set cookies on static paths. Where a response must carry one, or is personalized by a cookie, mark itprivate: a shared cache such as a CDN must then not store it, so that file is cached only in browsers. - 4What changes when files are precompressed? The compressed and uncompressed files are two representations behind one URL, so responses need
Vary: Accept-Encoding, and RFC 9110 states that a strongETagfor a content-encoded representation has to be distinct from that of the unencoded one, to prevent conflicts during cache updates and range requests. Servers differ in how much of this they do for you. nginx’sgzip_staticsends an existing.gzfile in place of the regular file, but it addsVary: Accept-Encodingonly whengzip_varyis on, which is not the default. Neither of the two nginx module pages says how theETagof a.gzresponse is formed, so request a file with and withoutAccept-Encoding: gzip, confirm fromContent-Encodingthat only the first response is compressed, and compare theVaryandETagheaders of the two responses. Repeat the check through the CDN:gzip_staticalso takesgzip_proxiedinto account, and its default,off, disables compression for requests that carry aViaheader, so a request forwarded by a CDN may receive the uncompressed file. Apache’smod_deflate, which compresses on the fly, appends the compression method to theETagby default, and its documentation says this prevents 304 responses to conditional requests for compressed content.
When Static Content matters
Apply long cache lifetimes when each content revision has a unique URL, reducing latency and origin load. Shorter caching or revalidation is safer when a stable URL may receive updates.
How Transloadit helps with Static Content
Files that an Assembly exports with a storage Robot are static content from then on: they sit in your bucket under the path you chose, and your storage or CDN serves them. The /s3/store Robot takes a headers object that is set on the stored file, and /video/adaptive gives each segment and playlist a relative_path so that the stored layout matches what the playlists reference. Smart CDN is the on-demand counterpart: a result is generated when it is first requested and then cached, and the /file/serve Robot sets the Cache-Control header that browsers and the CDN receive, with cache_duration to change it.
A browser player that loads HLS or MPEG-DASH files from a different origin than the page, such as a bucket or CDN hostname, needs CORS headers on the server that serves the files; the /video/adaptive page lists them. Cache headers for exported files are your storage’s or CDN’s responsibility once the files are stored.
Sources
- RFC 9111: HTTP Caching (heuristic freshness, authenticated requests, Set-Cookie)
- RFC 9110: HTTP Semantics (ETag and entity tags for content-encoded representations)
- MDN: HTTP caching (heuristic caching, validation, cache busting, main resources)
- Cloudflare: default cache behavior and cached file extensions
- nginx: ngx_http_gzip_static_module
- nginx: ngx_http_gzip_module (gzip_vary)
- Apache HTTP Server: mod_deflate (DeflateAlterETag, pre-compressed content)