Static sites rely on efficient caching to reduce load times and bandwidth. This article outlines how to set appropriate Cache-Control headers for different file types, ensuring fresh content delivery while maximizing cache reuse through versioned assets and correct directive usage.

Scenario: Updating a Static Site with New Assets

As a hypothetical case, picture an independent owner preparing a static site refresh: a new stylesheet, a revised font file, and a small script bundle. Her working checklist has three rows — Asset, Current header, Planned header — with candidate entries she wants to classify. One row reads “/assets/site.css | Cache-Control: public, max-age=31536000, immutable”; another reads “/assets/notes-v2.js | Cache-Control: no-cache”; a third reads “/assets/logo.svg | Cache-Control: public, max-age=604800”. She adds two fictional example records to see how they sit in the table: “/assets/menu.css | public, max-age=31536000, immutable” and “/assets/hero-v3.jpg | public, max-age=604800”. The versioned filename is treated as safe to cache for a year; the unversioned notes script stays revalidated each time, a deliberate trade-off favoring freshness over fewer requests. The logo sits in the middle because it changes occasionally.

She also keeps a short inventory for the swap: old file, new file, and the page where the reference changes. Entries look like “site.css → site-2026-04.css — every page” and “notes.js → notes-v2.js — documentation page only”. Before editing, she plans a quick local check of response headers in a terminal utility, noting what she expects to see rather than treating any output as confirmation. The header values are examples she records by hand; spelling in the table is her own filing convention, not a promise about what any server will echo. Finally, she writes a rollback note: keep the previous filenames on the server briefly and point references back if a page breaks. These are working notes for the scenario, not evidence of a live deployment or a measured outcome.

Understanding Freshness and Age in HTTP Caching

MDN documents that a stored response is fresh while its age is below the lifetime set by max-age, and stale once age exceeds it, where age is the time elapsed since the response was generated. In the guide's example, max-age=604800 makes a response fresh for one week.1

The same source states that a response remains reusable while fresh, and that a shared cache can report how long it has held a response by sending an Age header. In the example, a client receiving Age: 86400 finds the response fresh for the remaining 518400 seconds, the difference between max-age and Age.1

You can decide how much detail your own freshness notes need by starting with one asset you already plan to change and writing two versions of its header choice side by side. For a revised stylesheet, you might note “max-age=3600, public” for the first week after upload, with a short reason: browsers recheck hourly while you confirm the layout holds. Beside it, write the older choice you rejected, such as a one-year max-age, and why it felt risky that week. This comparison belongs in your own notes, not in the published file.

For each entry, consider adding three small fields you fill yourself: the asset name, the freshness window you chose, and a reminder of when you next expect to revisit it. A filled example might read: “site-2026-04.css — one hour — revisit after launch checks.” If you later archive that stylesheet, keep the same three fields and change only the asset name, so your current and archived notes stay comparable without rewriting the whole record.

You might also record, in one sentence, what “fresh” means for a given file in your own words, then adjust that sentence once you have reviewed the actual response in a browser’s network panel. These are preparation steps you can skip, shorten, or expand; the point is a record you can read later rather than a fixed template.

Configuring Long-Term Caching for Versioned Static Assets

For versioned static assets, the documented pattern is to add a version or hash to the filename or query string, so updated content gets a new URL and caches are not reused. With that cache-busting pattern in place, the guidance is to add a long max-age value together with immutable because the content will never change; its example sets max-age to one year and adds immutable. The immutable directive tells a cache the response will not be updated while fresh and avoids unnecessary conditional requests when a user reloads.2

The same guidance applies no-cache to the HTML response itself, so the client revalidates and receives a new version of the HTML and its asset references. One stated caveat: if the HTML is under Basic or Digest Authentication, assets are not stored in a shared cache, and suitable shared-cache storage also needs public, s-maxage or must-revalidate.2

Consider one file you already plan to replace, such as a stylesheet named site.css, and write its header choice both before and after versioning. The old form might read as a short freshness window with revalidation, while the versioned file site-2026-04.css could carry a long freshness window because its name changes whenever its contents change. You can decide which form suits each asset rather than applying one rule everywhere.

For a small comparison list, you might fill three fields yourself: the asset, the freshness window you chose, and the page that references it. A filled row could say “site-2026-04.css — long window — home page.” Another row for a font file might note a medium window if you are unsure how often it changes; that choice is yours to revise.

You can also write one plain sentence describing what “fresh” means for that file in your own words, then revisit the sentence after you review how the asset is actually requested. If a filename never changes, you might keep the shorter window and let the browser ask again. Neither choice is mandatory; record whichever you pick so the next replacement is easier to reason about.

Setting No-Cache Directives for Dynamic HTML Entries

The no-cache response directive allows a response to be stored in caches, but requires it to be validated with the origin server before each reuse, even when the cache is disconnected from the origin server. According to the MDN Cache-Control reference, it does not mean "don't cache": to prevent storing a response, use no-store instead.2

The same reference describes no-cache as suitable when caches should always check for content updates while reusing stored content, and gives a static-site example of applying it to the HTML response itself. It also notes that no-cache does not guarantee revalidation for history navigations such as the Back button, and that browsers may still serve a cached response without revalidating.2

For the dynamic HTML entry you identified, you can now draft a no-cache directive before you touch the file itself. Write the entry name plainly, then the header line you intend to use, such as “entry page — Cache-Control: no-cache, must-revalidate,” and add one sentence saying why you want the page rechecked each time. This is a planning note, not a deployment; you decide whether the entry stays in your working list or moves to a “ready to apply” column once you have looked at your own server response.

You might also prepare one before-and-after pair so the intent stays visible. For the before text, record the current directive you believe applies; for the after text, write the proposed no-cache line and name the page that links to the entry. A filled example could read “asset: news.html — current: no explicit header — proposed: no-cache, must-revalidate — referrer page: index.html.” You can choose a different column order, as long as the entry and its destination remain easy to trace.

As a separate demonstration, an archived entry for an older announcement page can use the same fields but point to a past date note instead of an active page. You might fill “asset: notice-2025.html — current: no-cache — proposed: keep as is — destination: archive index.” The choice of whether to preserve or revise that directive is yours; the fields simply keep both decisions comparable.

Resolving Conflicting Cache-Control Directives

When directives conflict, MDN states in theory the most restrictive directive should be honored. Its example combines private, no-cache, no-store, max-age=0, and must-revalidate in one header and calls it basically meaningless, equivalent to no-store alone, because the other directives conflict with no-store. So if your goal is preventing storage, the page points to no-store rather than no-cache, since no-cache permits storage but requires revalidation before reuse.2

The page also notes that max-age=0 with must-revalidate is equivalent to no-cache, but it advises simply using no-cache instead.2

For the dynamic HTML entry you identified, draft a no-cache directive before editing the file. You can write the entry name plainly, add the header line you intend to place above it, and note the date you plan to apply the change. A filled example might read: “index.html — Cache-Control: no-cache — apply before the March refresh.” This keeps the intent visible without implying the header is already live.

You might also prepare a before-and-after pair so the change stays traceable. For the before text, record the directive you believe currently applies; for the after text, write the replacement and a one-line reason, such as “needs revalidation because the page lists rotating announcements.” Keep both versions side by side rather than overwriting the note, so you can compare them later.

As a separate demonstration, an archived announcement page can use the same fields but point to a past date note instead of an active page. Your row might read: “archive/2024-notice.html — Cache-Control: max-age=3600 — dated December note.” Using the same fields for current and archived entries makes the distinction between an active page and a historical one easier to spot when you review your notes.

Best Practices for Heuristic vs Explicit Caching

Heuristic caching occurs when no Cache-Control header is given: the source states that responses meeting certain conditions are stored and reused anyway. Its example is a response last updated one year earlier, which “will not be updated for some time after that.” Reuse duration is left to the implementation, with the specification recommending about 10% of the time since storing.1

The source treats heuristic caching as a workaround predating widespread Cache-Control support and states that basically all responses should explicitly specify a Cache-Control header. Explicit max-age defines freshness by elapsed age: below one week is fresh, above one week is stale in the source's example, while Expires gives a time and is superseded by max-age when both are present.1

For the asset you have already chosen, you can now settle the heuristic-versus-explicit question in writing before you touch any server configuration. Take the stylesheet entry you recorded and add one field called “caching basis.” Fill it with a short phrase of your own, such as “explicit one year” for the versioned file or “heuristic, no guidance given” for a file whose freshness you are still unsure about. Completing that field forces you to name what you actually intend rather than leaving the outcome to whatever default the browser applies.

You might then write a paired sentence for each basis. For an explicit choice, one plain line could read “this versioned file stays fresh for one year because its name changes with each edit.” For a heuristic case, you could write “this file has no explicit window, so browsers may estimate freshness from the last modification date.” Keeping both sentences side by side lets you compare which assets genuinely need an explicit directive and which can reasonably be left to a browser estimate.

Finally, consider marking each row with a short note about how confident you are in the choice, for example “firm” or “revisit after the next file swap.” That note is for your own record only, and it gives you a simple cue when you return to the list and decide whether a heuristic entry should become an explicit one.

Frequently asked questions

What three column headings might I use when organizing a hypothetical static site refresh checklist?

As a hypothetical case, picture an independent owner preparing a static site refresh: a new stylesheet, a revised font file, and a small script bundle. Her working checklist has three rows — Asset, Current header, Planned header — with candidate entries she wants to classify.

What fields might I keep in a short inventory for swapping old files for new ones?

She also keeps a short inventory for the swap: old file, new file, and the page where the reference changes. Entries look like “site.css → site-2026-04.css — every page” and “notes.js → notes-v2.js — documentation page only”.

What three small fields could I add for each entry in my own freshness notes?

For each entry, consider adding three small fields you fill yourself: the asset name, the freshness window you chose, and a reminder of when you next expect to revisit it. A filled example might read: “site-2026-04.css — one hour — revisit after launch checks.”