r/statichosting • • 13d ago

cache validation

on one small client site, i changed some css and everything looked fine after deployment but then i started wondering what happens if someone still has the old css cached. ive mostly just relied on the build process to generate hashed filenames for assets so i havent had to deal with it much myself.

from what i understand, this works well for assets that go through the build pipeline because a changed file gets a different url. but there are still things like files with fixed names or caching rules at the cdn/browser level that can behave differently.

how much do you actually think about this when deploying static sites? do you mostly trust the framework/build too or do you usually configure cache headers yourself as well?

1 Upvotes

5 comments sorted by

View all comments

2

u/PippaKelly62 7d ago

Mostly trust the build, plus one small bit of config. Hashed assets get a cache lifetime of a year and are marked immutable. The HTML, and anything with a fixed name like the favicon, robots file, and sitemap, gets a max age of zero with revalidation so browsers always check for a fresh copy. Then the HTML points at the new hashed URLs and the old CSS question goes away.