This article explains how to use the Cache-Control header to manage browser caching for your online course platform. It covers strategies for versioned static assets, handling unversioned HTML files, and understanding freshness rules to improve load times without serving outdated content.
Setting Up Your Course Site's Caching Strategy
This is a hypothetical situation: an independent instructor is preparing a caching guide for a small course site built from static HTML, CSS, JavaScript, and a media folder. Her working notes contain no live site and no measured results—only draft examples she has devised to explain header choices.
Her first artifact is a draft table of Cache-Control rules the site owner could apply:
Page type | Example path | Draft header Course landing HTML | /courses/python-basics/index.html | Cache-Control: no-cache Versioned CSS bundle | /assets/css/main.7f3a2c.css | Cache-Control: public, max-age=31536000, immutable Lesson video file | /media/python-basics/lesson-01.mp4 | Cache-Control: public, max-age=604800
The landing page appears in the first row because the instructor wants browsers to revalidate it before showing updated prices or enrollment dates. The hashed stylesheet in the second row is treated as immutable because its filename already identifies a specific build. The video file sits between these choices: a week-long freshness window reduces repeat downloads, while a different filename would be needed after replacing the file.
Two working titles are on her desk for the guide: “Cache Rules for a Static Course Site” and “Planning Browser Caching Lesson by Lesson.” She keeps the first title for a general setup chapter and the second for a walkthrough that ties each rule to a lesson page, handout, or video. She favors the second title because it reminds readers to decide freshness by content type rather than by folder alone.
A second artifact is a short planning form, with two invented rows showing how she would classify files:
Draft field | Sample row 1 | Sample row 2 Content path | /courses/algebra/index.html | /assets/js/quiz.4b1d8e.js Change frequency | Weekly schedule updates | Each code release Chosen header | no-cache | public, max-age=31536000, immutable Reason for choice | Revalidate before display | Filename changes with build
The form moves from identifying a path to stating how often the content changes, then to the header and the reasoning. The rows themselves are illustrative notes for this example, not records from an existing course business.
One link example is written as a draft, with the destination and channel fixed by the author: an internal “Caching Checklist” link in the site’s instructor resources page points to the same page’s planning form section, delivered through the course management channel.
Using Cache Busting for Versioned Static Assets
For static assets built with versioning or hashing, MDN describes adding a version or hash to the filename or query string as a way to manage caching. The documented examples are a numbered library file such as react.0.0.0min.js and an image URL carrying a hash query. Because the content at that URL never changes, the original page says a long max-age value and immutable can be added, showing a header of max-age=31536000, immutable for the assets path.1
When the library is updated or the image edited, new content should have a new URL so caches aren't reused; MDN calls this the cache-busting pattern. The page also says no-cache should be used for the HTML response itself, so the client receives the new HTML and static asset versions. It notes that under Basic or Digest Authentication, files under the assets path are not stored in the shared cache unless public, s-maxage, or must-revalidate is also present.1
The next step is to take the draft table you already assembled and give each versioned asset a filename change that matches its header. Consider the hashed CSS bundle row: if you rename main.css to main.7c3a91.css after a redesign, you can pair it with a long max-age, while the HTML page that references it keeps no-cache so the new filename is discovered on the next visit. You might record the old and new names side by side in a scratch column, then decide whether the hash is worth the rename or whether a query suffix suits your build habit better; either choice is yours.
A second small exercise is to write two candidate filename patterns for the same script and mark which one you would pick, with a one-line reason. For example, quiz.4b1d8e.js versus quiz.js with a dated query. The first keeps the path stable and lets you cache for a year; the second is easier to type but risks stale copies if the query changes inconsistently. Neither is required—your notes can simply show the comparison and why one version label helps you spot which files changed between releases.
Handling Unversioned URLs and Server Revalidation
For unversioned URLs, the HTTP Cache alone cannot avoid the network completely. The source lists Cache-Control values to fine-tune caching for these URLs: no-cache requires the browser to revalidate with the server before every use of a cached version; no-store tells the browser and intermediate caches such as CDNs never to store the file; private allows browser caching but not intermediate caches; public allows any cache to store the response. Cache-Control can also accept a comma-separated list of directives.2
Setting ETag or Last-Modified can make revalidation more efficient. The source recommends ETag as more accurate; when a revalidation request matches, the server can respond with 304 Not Modified and include Cache-Control: max-age=120 in its example.2
You can take one fixed URL from your working notes, such as /courses/algebra/index.html, and draft two header candidates side by side: one with no-cache and one with a short max-age plus must-revalidate. Write a one-line reason under each, then mark which you would keep if the schedule changes weekly. The choice stays yours; the point is to see how revalidation behaves when the filename never changes.
For a media file with a stable name, try the same exercise with a longer max-age and note in plain words what a returning visitor might see after you replace the file. If the answer feels wrong for your lesson materials, adjust the number rather than the filename.
If you later decide to rename an unversioned file instead, you can record that decision in the same note: old path, new path, and the header you plan to pair with each. This keeps the comparison visible when you revisit the guide, without implying that any choice has been tested.
Understanding Freshness, Age, and Stale Responses
A stored response is either fresh or stale. Age is the time elapsed since the response was generated, similar to a TTL. With Cache-Control: max-age=604800, a response younger than one week is fresh; older than one week, it is stale. While fresh, it fulfills client requests.3
A shared cache can report age to the client: after storing the response one day, it sends Age: 86400, and the client finds the response fresh for the remaining 518400 seconds.3
Expires specifies an explicit time; max-age specifies an elapsed time. Where both are available, max-age is preferred. Stale responses are not discarded: validation with If-Modified-Since or If-None-Match can make one fresh again, with 304 Not Modified when unchanged.3
Take the versioned CSS row you already drafted and annotate it with two plain-language notes: one beside the header saying the browser may reuse the file without asking until the maximum age passes, and one beside the filename saying a new hash starts a fresh lifetime. You can add a third note for the in-between case, where a cached copy has aged past its freshness limit but a revalidation fails; decide whether your draft should let that copy be served or treat it as unusable, and write the reason you chose. Then revisit the landing page row and record, in the same style, what you expect a returning visitor to see if the page is revalidated versus reused without a check. These are notes about your draft, not claims about how any browser behaved.
For a media file with a stable name, you might draft two candidate notes side by side: one describing a visitor who returns after a month, and one after a year, each stating whether you would expect the file to be fetched again and what visible change would prompt that expectation. If neither note feels right, consider whether renaming the file is a simpler answer for your draft, and record old path, new path, and intended header in the same note. Choose whichever pair of notes best matches how often you plan to replace that file, and keep the unchosen pair as a comparison you can revisit later.
Avoiding Conflicting Directives in Header Configuration
For this section, follow what the source states about conflicting directives: in theory, if directives are conflicted, the most restrictive directive should be honored. The source gives the example Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate as conflicted and "equivalent to" no-store alone.1
When writing header values, separate multiple directives with commas. Directives are case-insensitive, though lowercase is recommended because some implementations do not recognize uppercase.1
Take the working table you already drafted and check for pairs of directives that would pull in opposite directions. Consider marking any row that pairs no-cache with a long max-age, or private with a shared-cache allowance, and writing beside it which instruction you intend the browser to follow. You can then revise the row so only one caching intent remains.
For a concrete pass, you might take your versioned CSS row and rewrite the header as a single clear instruction, leaving the filename change untouched. Note in plain words why the shortened header matches that row better than the original pairing.
You can also draft two candidate notes for the same stable media file: one where a returning visitor is told to check back with the server, and one where the file may be reused for a long period. Mark which note you would attach to the header and give a one-line reason.
If a row still feels contradictory, consider setting it aside as an open question rather than settling it now. Record the path, the two directives in tension, and the choice you are leaning toward, so your later revision has a clear starting point.
Practical Steps for Implementing Cache Headers
Take the short planning form you already drafted and add one column for a “review date,” then fill two invented rows to see how the column works. For the course landing page, you might write a review date of “next price change” beside the no-cache choice. For the hashed CSS bundle, a date such as “next bundle rebuild” works better, because the filename itself will change when the content does. Both values are examples you can adjust; the point is to pair each header with a moment when someone will look at it again rather than letting the table sit unchanged.
A second pass is to read your own table aloud as if explaining it to a colleague who has never touched a header. Where the reasoning in the right-hand column sounds like shorthand only you understand, rewrite that cell in one plain sentence. You can keep the same header and path; only the explanation changes. Consider marking any row you cannot explain in a sentence as a question for later, since an unexplained rule is the one most likely to be copied by mistake.
You might also set the table aside for a day, then return and check whether any two rows now seem redundant. If two assets share the same change rhythm and the same header, you can merge them into one row and note both paths in the same cell. This keeps the guide compact without hiding a rule. Continue until each row earns its place, then stop; a short table you can defend is more useful than a long one you cannot.
Frequently asked questions
How can I compare two header candidates for one fixed URL from my working notes and mark which I would keep if the schedule changes weekly?
You can take one fixed URL from your working notes, such as /courses/algebra/index.html, and draft two header candidates side by side: one with no-cache and one with a short max-age plus must-revalidate. Write a one-line reason under each, then mark which you would keep if the schedule changes weekly.
How should I mark and explain rows in my working table where two directives pull in opposite directions?
Take the working table you already drafted and check for pairs of directives that would pull in opposite directions. Consider marking any row that pairs no-cache with a long max-age, or private with a shared-cache allowance, and writing beside it which instruction you intend the browser to follow.
How can I add a review date column to my short planning form and fill sample rows to see how it works?
Take the short planning form you already drafted and add one column for a “review date,” then fill two invented rows to see how the column works. For the course landing page, you might write a review date of “next price change” beside the no-cache choice.
Cache-Control header - HTTP | MDN . Retrieved 2026-11-21. ↩︎ ↩︎ ↩︎ ↩︎
Prevent unnecessary network requests with the HTTP Cache | Articles | web.dev . Retrieved 2026-11-21. ↩︎ ↩︎
HTTP caching - HTTP | MDN . Retrieved 2026-11-21. ↩︎ ↩︎ ↩︎