brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Cache-Control no-cache still stores a response, only no-store forbids it

Cache
~/tips/tip-cache-control-no-cache-no-store

Cache-Control: no-cache

Pick the right header for fresh pages versus pages that must not be saved.

The name no-cache fooled me when I first read it, and I suspect I am not alone. It allows storing. What it demands is a check with the server before the copy is used again.

The two headers:

Cache-Control: no-cache
Cache-Control: no-store

With no-cache, the browser keeps the response and asks the server each time whether it is still current. If the server answers 304 Not Modified, the stored copy is used and little data moves. That suits an HTML page that must always be up to date.

With no-store, caches are told not to keep the response at all. Use it for things like a page with account details on a shared computer.

Check what your site sends:

curl -sD - -o /dev/null https://example.com/account

For no-cache to save bandwidth the server needs to send an ETag or Last-Modified, otherwise every check downloads the whole thing again. Adding no-store everywhere to be safe throws away speed for nothing. Also, a copy saved before you changed the header can live on until it expires.

Further reading: MDN: Cache-Control

Going deeper: Guide: your Unraid cache is full and Docker stopped, how to find out why and fix it

More Cache tips fincore /var/lib/example/data.db npm cache verify fc-cache -f -v ~/.local/share/fonts proxy_cache app; Cache-Control: max-age=60, stale-while-revalidate=600 All Cache tips (24) All topics

Link