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: send If-None-Match with curl to see whether the cache validator gives a 304

Cache
~/tips/tip-cache-if-none-match-304-check

curl -sI -H "If-None-Match: $etag" https://example.com/app.js | head -1

Sends the stored ETag back to the server to check that it answers 304 Not Modified.

A cache that never answers 304 wastes bandwidth on every revisit.

etag=$(curl -sI https://example.com/app.js | awk -F': ' 'tolower($1)=="etag" {print $2}' | tr -d '\r')
curl -sI -H "If-None-Match: $etag" https://example.com/app.js | head -1

The first line saves the ETag of the file, the second repeats the request the way a browser does when its copy is stale. HTTP/2 304 means the validator works and no body was sent. A 200 means the server ignores the header, which often happens when two backends generate different ETags for the same file. Keep the quotes that are part of the ETag value, and for a weak ETag the W/ prefix as well. If-Modified-Since works the same way for Last-Modified.

Further reading: MDN: HTTP conditional requests

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: no-cache All Cache tips (24) All topics

Link