Caching
Cache-Control
Set freshness and storage rules with max-age, public, private, no-cache, no-store, and immutable response directives.
9 minute lesson
~~~
Cache-Control contains directives for caches.
Cache-Control: public, max-age=3600
This response can be stored by shared caches and remains fresh for one hour.
Useful directives include:
private: only a private cache should store it.no-store: do not store the response.no-cache: storage is allowed, but validate before reuse.max-age=60: fresh for 60 seconds.immutable: the URL’s content will not change while fresh.
no-cache is often misunderstood. It does not prohibit caching. It requires a check before reuse.
Versioned assets such as /app.a1b2.css can use a long lifetime and immutable. When the file changes, its URL changes too. Personalized account pages usually need private or no-store.
Lesson completed