Networking & HTTP·Networking from DNS to production

Headers and caching

Read content types, cache directives and conditional requests.

Beginner 14 min read Lesson 5 of 300 Challenge included
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.

headers.httpHTTP
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-Encoding
Your turn

Cache a hashed asset

Easy

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 in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: TLS
Lesson 5 of 300 · 0% of course