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: immutable stops revalidation of a cache-busted file

Cache
~/tips/tip-cache-cache-control-immutable-hashed

add_header Cache-Control "public, max-age=31536000, immutable";

Marks fingerprinted files as never changing so browsers skip revalidation on reload.

Files with a hash in their name never change, so the browser should not ask about them.

location ~* \.[0-9a-f]{8}\.(css|js|woff2)$ {
  add_header Cache-Control "public, max-age=31536000, immutable";
}

This matches names like app.4f2a9c1d.js and gives them a one-year lifetime. immutable tells browsers that support it not to revalidate the file when the user reloads the page. It is only correct when the file name changes with every content change, which build tools do with a content hash. A fixed name such as style.css with this header can get stuck in browsers for a year. Remember that add_header in a location replaces the headers inherited from the level above.

Further reading: MDN: Cache-Control header

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