Headers and caching
Read content types, cache directives and conditional requests.
What you will be able to do
- Set Content-Type correctly.
- Use Cache-Control: public, max-age with immutable for hashed assets.
- Use no-store for private data.
- Use ETag for revalidation.
In plain English
Headers carry metadata: Content-Type, Content-Length, Cache-Control, ETag and Authorization. Cache-Control tells browsers and CDNs what they may store. Conditional requests with ETag or If-None-Match avoid re-sending unchanged content.
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: public, max-age=60, stale-while-revalidate=300
ETag: "v1-abc"
Vary: Accept-EncodingYour turn
EasyCache a hashed asset
Write a Cache-Control value for an immutable hashed asset.
HTTP · starter
Cache-Control:Check your understanding before moving on.
Knowledge checkQuestion 1
Which directive prevents a response from being cached?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.