Local studio operators often manage static sites where content changes frequently while assets remain stable. Understanding how to configure cache headers ensures visitors receive the latest updates without unnecessary server load. This article explores practical steps for setting appropriate directives for different file types, focusing on balancing freshness and performance for small-scale web projects.
Assuming a Static Site with Frequent Text Updates
As a hypothetical example, picture a two-person studio that publishes a small static site for a neighborhood workshop: one HTML file per page, a shared CSS file, one logo image, and a handful of font files. Text changes most weeks, the logo appears on every page, and a versioned stylesheet is rebuilt only when design changes. The operator's scratch sheet lists candidates such as "index response, no-store", "stylesheet, one-year immutable", and "logo image, one-month revalidate" — names of their own, not entries copied from documentation.
Their first split is textual versus stable. For the page documents, the draft header is Cache-Control with no-cache, not no-store, because the files are ordinary static output and the goal is revalidation rather than prohibition. For rewritten assets carrying a fingerprint in the filename, the draft is public, max-age set to one year, and immutable. For images that keep a fixed name, the draft is public with a shorter max-age and must-revalidate. The reasoning is one deliberate trade: giving up instant freshness on the unhashed logo in exchange for fewer full transfers, while page text stays revalidated on every visit.
A worked item from the sheet shows the pattern. Field "URL path" holds /assets/site.a1b2c3.css; field "fingerprint present" holds yes; field "header" holds public, max-age, immutable. A second record carries /assets/logo.png, fingerprint no, header public with a short max-age and must-revalidate. The labels merely organize the author's own choices, and the version string is invented for the illustration.
Before publishing, the operator's list notes what still needs checking: whether the host itself injects a default header, whether a middle caching layer rewrites directives, and whether the validation and combined values behave as drafted. No response has been observed yet, and nothing here predicts how a particular host or intermediary will treat these headers. The next step is to run the same paths through a header inspection tool, compare the returned values against this sheet, and adjust only the mismatched entries.
Identifying Which Files Need Freshness vs Stability
Before you touch a header, consider making one short sheet that lists each file you actually publish, sorted by how often its contents change. A practical set of fields might be: file purpose, change frequency, name changes on edit, and planned header. Filled in for a small site, it could read like this: “home page; edited most weeks; filename stays the same; no-cache” and “shared stylesheet; edited a few times a year; name includes a short fingerprint; public max-age plus immutable.” You can add rows for images, fonts, and any downloads, since each may deserve a different answer.
The sorting question is whether an edit to the file can be expected soon after publishing, or whether the file is effectively frozen once released. Text documents such as the home page, an about page, or a contact page are the usual candidates for the first group, because you want a visitor to see a correction without waiting. Stylesheets, scripts, and fonts tend to fall into the second group, especially when you rename them with each revision. You might mark that column “stable” and decide that a longer lifetime is acceptable there.
Naming is where the two groups meet your publishing habits. If you plan to keep calling a file site.css forever, you may prefer a shorter lifetime so a rewrite reaches people quickly. If you are willing to rename it to site.a1b2c3.css on every change, the older name can stay in caches while the new page points elsewhere. Consider writing that decision down next to the row rather than leaving it in your head; a later edit becomes much easier to judge.
You can also keep a small “review when” note per row, such as “after the next seasonal update” or “when the logo changes.” That note is not a promise about how any server behaves; it simply tells you which entries to revisit first. Your final sort is yours to choose, and the sheet should make each choice visible rather than assumed.
Setting Long-Term Caching for Versioned Assets
For versioned or hashed static assets, MDN documents adding a long max-age value together with immutable, shown as Cache-Control: max-age=31536000, immutable for the assets path. MDN explains this fits the cache-busting pattern: the URL is numbered or hashed, the file is never modified, and when content changes a new URL is used so caches aren't reused. MDN notes that when a user reloads, the browser sends conditional requests to validate; because such static resources are never modified, immutable tells the cache the response won't be updated while fresh and avoids those unnecessary conditional requests.1
You can take the versioned assets from your sheet and give each one a long lifetime, while treating the unversioned page documents differently. A practical next step is to write the candidate header beside each fingerprinted row and add a second field recording what would make you revisit it. For example, a row for the shared stylesheet might read: path, /assets/site.a1b2c3.css; fingerprint, yes; candidate header, public, max-age one year, immutable; review when, the next full rebuild changes the hash. You can fill the same two fields for a script bundle and a font file, then compare the rows side by side.
You might also record why each asset earned a long lifetime. If the filename itself changes whenever the contents change, a one-year lifetime is easier to justify; if you sometimes overwrite the same filename in place, consider a shorter lifetime for that row instead. The point is not to settle on one number for everything, but to make your choice visible and repeatable across assets.
Before publishing, you can mark each long-lifetime row with the date you last changed the file, so a future edit against the same filename stands out rather than slipping through. This keeps your sheet useful as a record of decisions you have made, not a list of tasks still pending.
Configuring No-Cache for Main HTML Pages
For the main HTML pages, the no-cache response directive is the one the MDN Cache-Control reference describes for this purpose: it says to use a no-cache directive to make sure the HTML response itself is not cached. The same page is explicit that no-cache does not mean “don't cache”: it allows caches to store a response but requires revalidation with the origin server before each reuse, even when the cache is disconnected from the origin server. If the intent is actually “don't store,” the reference points to no-store instead.1
The reference gives the header as Cache-Control: no-cache, and notes the directive is case-insensitive with lowercase recommended, and that multiple directives are comma-separated. It also cautions that no-cache does not guarantee revalidation for history navigations such as Back-button use, where bfcache or even a non-bfcache browser may serve the cached response without revalidating.1
You can take the same sheet you used for the fingerprinted assets and add a column for page documents. For each main HTML file, record the path, the current value of the HTTP Cache-Control header, and a short note about how recently the text changed. Set the header so the page stays in the cache but is revalidated before reuse—no-cache keeps the stored copy and asks the server or your hosting layer whether it still matches, which suits a page whose wording changes without a new filename. Record that choice next to the file, and if a page later becomes effectively frozen, you can move it to a longer lifetime instead.
Consider whether each page is edited often or rarely. A frequently updated announcement page might carry no-cache while a rarely touched contact page could carry a short lifetime. Note the reason beside each row so a later review can follow your thinking.
Verifying Header Directives in Server Configuration
In the ngx_http_headers_module documentation, the expires directive controls both the Expires and Cache-Control response header fields. A negative time produces Cache-Control: no-cache, while a positive or zero time produces Cache-Control: max-age=t, where t is the directive's time in seconds. The epoch parameter sets Cache-Control to no-cache, and max sets it to 10 years; the off parameter disables adding or modifying both headers.2
The add_header directive adds a named field, such as Cache-Control, to a response header, and its value can contain variables; according to the documentation, the field is added only for certain response codes unless the always parameter is specified. The add_header_inherit directive, available since version 1.29.3, defaults to on and can be set to merge or off to change how add_header values are inherited across configuration levels.2
You can take the sheet you filled out for each published file and use it as the basis for checking what the server will actually send. Pick one row at a time and note, beside the header you intended, what you expect the response header to say when that path is requested. For example, the row for the versioned stylesheet might read “intended: public, max-age one year” and “expected response: same”; the row for a main page document might read “intended: no-cache” and “expected response: same.” You can then decide whether to compare those expectations against what your configuration file actually contains before publishing, or to ask whoever maintains the server to confirm it.
You might treat the comparison as a reading exercise rather than a test. Open the server configuration file and look for the section that handles the relevant paths, then check whether the directive there matches the intended value in the row. If the file groups static files by extension or by folder, you can note which group each sheet row falls into and whether two rows with different intended headers end up under the same group; that is a reason to split them or to keep the settings separate.
It helps to record the reason for any mismatch you spot, not only that it exists. A note such as “page documents share a group with assets; intended values differ” gives you a clear choice later: adjust the grouping, or change the intended value for one row. You can keep this as a short column in the same sheet rather than a separate document, so each entry stays next to the path and header it describes.
Testing Cache Behavior After Deployment
After you publish, you can compare what your sheet says each file should receive with what the response actually carries. Pick one row at a time, note the path and the intended value, then read the header on the live response and write down what you see. Keep the two columns side by side so a difference is visible rather than remembered.
If a page document comes back with the long lifetime you meant for a versioned asset, that is worth flagging on the sheet before you edit anything. For example, a row for /index.html might list “intended: no-cache” while the observed header shows a one-year lifetime; you might write the reason as “page documents share a group with assets” rather than just “wrong.” That note helps you decide whether the grouping or the individual row needs attention.
You can also check that the asset rows still behave as planned after a routine content update: change one page, publish, and confirm the fingerprinted asset path still resolves to the same file while the revised page carries its shorter lifetime. If the filenames changed, update the affected rows so the sheet keeps matching what you release.
Not every mismatch needs fixing right away. You might mark a row as “revisit after the next seasonal update” when the difference is harmless for now, and leave a separate note for anything that could keep an outdated page visible. The point is a short, readable record of what you intended, what you saw, and why you chose to act or wait.
Frequently asked questions
How can I start organizing the files I publish before dealing with any headers?
Before you touch a header, consider making one short sheet that lists each file you actually publish, sorted by how often its contents change. A practical set of fields might be: file purpose, change frequency, name changes on edit, and planned header.
When sorting my files, how do I decide whether an edit is likely soon or the file is effectively frozen?
The sorting question is whether an edit to the file can be expected soon after publishing, or whether the file is effectively frozen once released. Text documents such as the home page, an about page, or a contact page are the usual candidates for the first group, because you want a visitor to see a correction without waiting.
How can I keep track of which sheet rows to revisit first?
You can also keep a small “review when” note per row, such as “after the next seasonal update” or “when the logo changes.” That note is not a promise about how any server behaves; it simply tells you which entries to revisit first.
Cache-Control header - HTTP | MDN . Retrieved 2026-11-21. ↩︎ ↩︎ ↩︎
Module ngx_http_headers_module . Retrieved 2026-11-21. ↩︎ ↩︎