https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Caching
What it does
- Lets the client reuse cached responses
- Reduces bandwidth
- Reduces latency
- Reduces load on your server
How it works
You send headers like:
Cache-Control: max-age=3600
ETag: "abc123"
Last-Modified: Tue, 22 Feb 2022 22:00:00 GMT
Expires: ...
Then the browser may send:
If-None-Match
If-Modified-Since
If the resource hasn’t changed, you return:
304 Not Modified
Pros
Saves bandwidth
Makes the site feel faster
Offloads work to the client
Standard HTTP behavior
Cons
Client may ignore caching
Harder to invalidate (must change ETag or timestamp)
Doesn’t help with expensive server‑side work unless combined with server caching
https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Caching
What it does
How it works
You send headers like:
Cache-Control: max-age=3600
ETag: "abc123"
Last-Modified: Tue, 22 Feb 2022 22:00:00 GMT
Expires: ...
Then the browser may send:
If-None-Match
If-Modified-Since
If the resource hasn’t changed, you return:
304 Not Modified
Pros
Saves bandwidth
Makes the site feel faster
Offloads work to the client
Standard HTTP behavior
Cons
Client may ignore caching
Harder to invalidate (must change ETag or timestamp)
Doesn’t help with expensive server‑side work unless combined with server caching