Static site projects often struggle with outdated content or slow load times due to improper caching. This article addresses how to configure Cache-Control headers correctly, specifically using cache busting techniques and appropriate directives like no-cache and max-age to ensure users receive the latest assets while maintaining performance.
Scenario: A Static Site Project Facing Stale Asset Issues
As a hypothetical illustration, picture a documentation-focused project author preparing a static site for a release, with a build-output folder of fingerprinted CSS and JavaScript bundles, images, fonts, and a few repository-generated index files. The starting point is a blunt Cache-Control header, one max-age value applied to every path, which leaves returning visitors holding old styles after a deploy. The author decides to split the response policy by asset class rather than by folder name, because the same folder can mix hashed bundles with stable files.
The author drafts three line items for a small configuration table. The first row is “Fingerprinted bundles,” with a path pattern covering files whose names contain a content hash, a Cache-Control value of public, max-age=31536000, immutable, and a note that a new deploy changes the filename rather than the URL. The second row is “Unversioned media,” covering images and font files whose names do not change, with a value of public, max-age=86400 and a note to revisit after a visual refresh. The third row is “HTML entry points,” with a value of no-cache and a note that the browser may store the response but must revalidate before reuse.
Two fictional records show how the author would fill and classify such a table. A record labeled “Legacy brand hero image” falls under Unversioned media because its path lacks a hash, so the author expects repeat visitors to keep it for a day and marks it for review in the next visual pass. A record labeled “Home index page” falls under HTML entry points, so the author records revalidation as the required behavior and excludes it from the long-lived bundle policy. A fourth candidate, “Fonts used across releases,” is moved from Fingerprinted bundles to Unversioned media after the author notices the font files are copied with stable names; the reason recorded is filename stability, not file type.
These entries are working examples created to make the classification decision visible, not records of a deployed site or measured performance. The author keeps the row names stable across builds so that the table is easy to compare between source revisions, and treats each path pattern as an internal convention whose match is checked in the build output rather than in an external search or service.
Understanding Core Cache-Control Directives
A response's freshness is governed by directives in its Cache-Control header; for max-age, the N counts seconds from when the origin server generated the response, not from when a cache received it. In shared caches, s-maxage states how long the response stays fresh there, overrides max-age and Expires for shared caches, and is ignored by private caches. The private directive limits storage to private caches, and MDN says to add it for user-personalized content, especially responses after login and cookie-managed sessions.1
The no-cache response directive does not mean “do not cache”: it permits storage but requires validation with the origin server before each reuse. For a response that must not be stored by any cache, private or shared, the documented directive is no-store. The must-revalidate directive allows reuse while fresh but requires origin validation once stale, rather than permitting reuse during disconnection.1
Before you set a single header value, you can take stock of the static files your build already produces and sort them into two piles: names that change with every release and names that stay fixed. Consider writing each file’s role and current naming pattern into a short private note, then marking it “versioned” or “unversioned.” That note becomes the basis for your directive choices, not a public deliverable.
For versioned assets, you might draft a directive such as public, max-age, and immutable, and explain in your own words why a long lifetime is reasonable when the name itself carries the version. For unversioned media, a shorter max-age with revalidation invites browsers to check back rather than rely on a stale copy. Pair these with a plain-language sentence for each file type so a reviewer can see the reasoning without parsing syntax.
If you keep a field template, try these columns with filled examples: file group — fingerprinted CSS bundle; naming cue — hash in filename; chosen directive — long max-age with immutable; revalidation path — not needed until rename. For an archived announcement image, the same fields might read: file group — archived notice image; naming cue — fixed name; chosen directive — short max-age with revalidation; revalidation path — check on each visit. You can decide which pile a file belongs to before choosing any value.
Implementing Cache Busting for Versioned Assets
The cache-busting pattern adds a version or hash to a static asset's filename or query string, as in a script path carrying a version number or an image URL with a hash query. Because the content is never modified in place — updates ship under new URLs — the documented example pairs this pattern with a long lifetime and sets Cache-Control to max-age=31536000, immutable for the assets path. Immutable signals the response will not change while fresh and avoids unnecessary conditional requests on reload.1
When the library is updated or the picture edited, the new content should have a new URL so caches are not reused. The HTML response itself is kept out of caching with Cache-Control: no-cache on the index file, so revalidation lets the client receive the new HTML and the new asset URLs.1
With versioned assets in place, consider whether your current cache policy still lets a stale bundle linger under a name that never changes. One practical next step is to write a short before-and-after note for each asset group. For a fingerprinted CSS bundle, the “before” line might read “same filename across releases,” and the “after” line “hash changes when content changes.” That comparison gives you a reason to keep a long lifetime on the versioned file rather than shortening every header across the site.
For unversioned items, you can choose a different direction. A logo or shared script that keeps its name across releases may deserve a shorter lifetime or revalidation, and you might record that choice beside the asset in your own notes. A filled sample entry could be: asset group — shared site script; naming cue — no hash; chosen treatment — shorter lifetime pending review; reason — filename survives releases. This is a planning example, not a measured result.
If two candidate directives seem workable, you might write both and state your preference in one sentence, such as favoring the longer lifetime only where the filename itself changes. You can also note which entries remain undecided, so the next review of your asset list has a starting point rather than a fresh sort.
Configuring Headers for HTML Entry Points
For the HTML entry point itself, the documented example uses no-cache so the HTML response is not cached, with the note that this can cause revalidation and lets the client receive a new version of the HTML response along with the static assets it references. That example appears as a response header for the index path.1
The same page notes a conditional detail: if the index is under Basic or Digest Authentication, files under the assets path are not stored in the shared cache, and if those files are suitable for shared-cache storage you also need one of public, s-maxage, or must-revalidate. If you need a fallback form, max-age=0 with must-revalidate is described as equivalent to no-cache, though the page says to simply use no-cache for now.1
For the HTML entry point itself, you can treat the page shell differently from the assets it references. Rather than giving the document a long lifetime, consider a directive that keeps it fresh while still allowing conditional requests, then write out in plain words why this choice fits: the HTML is the piece most likely to point at a new fingerprinted bundle, so a stale copy can keep visitors on an older release even when the bundles themselves are versioned.
A worked writing example makes the distinction concrete. Take your existing configuration table and add one row for the entry document: file group — root HTML entry; naming cue — same name in every build; chosen directive — a short lifetime with revalidation; reason — references the current release's bundles. Compare it with the fingerprinted bundle row already in the table, where the hash in the filename justifies a long lifetime. You might write one sentence stating why the two rows diverge so a reviewer can follow the reasoning.
If your build emits several entry documents, decide whether they share one policy or need separate rows. For a hypothetical site with a marketing landing page and a documentation home, you can draft two rows with identical directives and a note that both change on each deploy. This keeps the table readable without collapsing distinct files into one vague entry.
You can also rehearse a revision: draft a version where the HTML gets a long lifetime like the bundles, then rewrite it to the short-lifetime form and keep a one-line note explaining what problem the revision avoids. The next step is to note which of your own entry files fit this row before you look at any shared media assets.
Balancing Freshness and Performance in Shared Caches
For shared caches, MDN describes two main types: private caches tied to a specific client, typically a browser, and shared caches located between client and server that can store responses shared among users. Shared caches include proxy caches, which are usually not managed by the service developer and must be controlled through HTTP headers, and managed caches such as reverse proxies, CDNs, and service workers with the Cache API. MDN notes that managed cache behavior can usually be controlled through the Cache-Control header plus the product's own configuration files or dashboards, and that some CDNs provide headers effective only for that CDN, such as Surrogate-Control, with work underway on a CDN-Cache-Control header. MDN recommends reading the documentation of whichever managed-cache mechanism you use and controlling it through the ways that mechanism provides, rather than relying on kitchen-sink headers.2
Take one concrete release artifact—your build’s output manifest or a short list of emitted files—and annotate it with two columns you control: whether the filename changes when content changes, and which shared-cache lifetime you are leaning toward. This gives you a small working record for weighing freshness against reuse before you settle on any header text.
For a fingerprinted stylesheet, you might write “name includes a content hash” and tentatively choose a long lifetime; for a logo reused across releases, write “same name each build” and lean toward a shorter lifetime with revalidation. For the root entry document, note that it carries no version cue and consider a brief lifetime so that new asset references appear promptly. Keep the column headings as your own questions: Does this name change with content? How long can a shared cache keep it without hiding a correction? Which tradeoff matters more for this file?
If two candidates remain, draft both directive lines side by side and add one sentence stating why one fits the naming cue better. You can revise that sentence when the next release changes your file list, and you might keep the previous note beside it so the shift in reasoning stays visible.
Common Misconfigurations to Avoid
Take one configuration table or header list you have drafted and widen it with one more column for the misconfiguration risk you want to catch before publishing. For each row, you can write a short phrase that names what could go wrong if the directive stays as drafted, then decide whether to keep the row, split it, or revise it. This is a writing check, not a test of any deployed site.
For example, take the row for a fingerprinted CSS bundle with a long lifetime. You might add the note “long lifetime attached to a name that later loses its hash,” which flags that the entry depends on the naming cue staying true. If that seems unlikely for your build, keep the row as is. If the naming could drift, consider splitting the row into a versioned entry and a fallback entry with a shorter lifetime, and say in one sentence which one you expect the build to emit.
For an unversioned logo, the risk column might read “short lifetime forces repeated revalidation during a campaign.” You can weigh that against the opposite risk, a stale image lingering after a redesign, and record your choice in a phrase such as “prefer freshness over repeat fetches for this asset.” Either direction is yours to pick; the point is that the note makes the tradeoff visible on the page rather than leaving it implicit.
For the HTML entry document, a useful risk phrase is “long lifetime pins the page shell to an old asset list.” You can revise that row toward a shorter lifetime or revalidation and add a plain sentence explaining that the document is the piece most likely to change between releases. If your project emits several entry documents, such as a landing page and a documentation index, you might give each its own row and risk note, since their update rhythms may differ.
Finally, read the table top to bottom and mark any row whose risk note contradicts its directive. For each conflict, draft a revised line and keep the original beside it for comparison, so your own notes show the choice you made and why.
Frequently asked questions
Before setting a header value, how can I sort the static files my build produces?
Before you set a single header value, you can take stock of the static files your build already produces and sort them into two piles: names that change with every release and names that stay fixed. Consider writing each file’s role and current naming pattern into a short private note, then marking it “versioned” or “unversioned.”
If I keep a field template for my own asset records, what columns and filled examples might I use?
If you keep a field template, try these columns with filled examples: file group — fingerprinted CSS bundle; naming cue — hash in filename; chosen directive — long max-age with immutable; revalidation path — not needed until rename. For an archived announcement image, the same fields might read: file group — archived notice image; naming cue — fixed name; chosen directive — short max-age with revalidation; revalidation path — check on each visit.
How can I annotate a release artifact with columns I control?
Take one concrete release artifact—your build’s output manifest or a short list of emitted files—and annotate it with two columns you control: whether the filename changes when content changes, and which shared-cache lifetime you are leaning toward.
Cache-Control header - HTTP | MDN . Retrieved 2026-11-21. ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎
HTTP caching - HTTP | MDN . Retrieved 2026-11-21. ↩︎