Browser cache freshness
Reuse a response without another download
A browser cache stores a response for possible later use. Freshness describes how long a stored response can normally be reused without contacting the server. It is not the lifetime of a file on disk. A fresh response can avoid a network request; a stale response usually needs validation before reuse. Nginx can communicate a policy without enabling its own proxy cache.
HTTP/1.1 200 OKCache-Control: public, max-age=600Content-Type: text/cssFor a simplified timeline with no pre-existing age, a response received at second 0 can be fresh at second 400 but stale at second 601. Actual age also accounts for time already spent in caches and transit. A cache may evict a response earlier; freshness does not guarantee storage.
Choose policies by resource type
Use short freshness or validation for documents that point to new assets. A filename derived from the bytes lets you publish a changed asset at a different URL. Give long freshness only to public files whose content will not change at that URL. Keep old assets available while older pages may reference them.
location = /index.html { add_header Cache-Control "no-cache" always;}location = /assets/app.f2fcf10e505c1e22.css { add_header Cache-Control "public, max-age=31536000, immutable";}location = /account { add_header Cache-Control "no-store" always; return 200 "synthetic private page\n";}The HTML can be stored but normally must be checked before reuse. The immutable stylesheet promises unchanged bytes during its freshness lifetime; a new release must change the filename if the bytes change. The account example is synthetic and has no authentication; real accounts require server-side authorization as well. The no-store policy directs caches not to retain the response. It is not a way to erase all previously stored copies or replace TLS.
Expires and shared caches
For an eligible response this sets a freshness lifetime of 600 seconds and an expiration date. When max-age is present it takes precedence over Expires for HTTP freshness calculations. A browser cache is typically private; a CDN may be shared across users. private restricts storage by shared caches, while s-maxage sets a shared-cache freshness lifetime. Do not mark user-specific or authorization-dependent responses public merely to improve speed.
Changing public HTML -> no-cachePublic hashed CSS -> public, max-age=31536000, immutableSynthetic account response -> no-storeCommon mistakes and practice
Do not apply a year-long lifetime to an unversioned index page: users may keep seeing references to obsolete assets. Do not confuse no-cache with no-store. Practice choosing policies for a news page, a versioned icon and a receipt. Next: conditional requests and validators. Static snippets are not a ByteMind execution exercise.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Browser cache freshness
Choose a cache policy for HTML, versioned assets and private data; understand freshness, expiration and the limits of shared caches.
A fresh public response is 200 seconds old and max-age=600. What is normally possible?
Which policy allows storage but requires validation before reuse?
What policy suits a synthetic sensitive receipt?
CSS bytes change after deployment. What should happen to its immutable URL?
Which cache does s-maxage target?