{"success":true,"name":"cache-assets-forever-by-hashed-filename-and-never-cache-the-","description":"After a deploy, some users see the old version or a broken mix","category":"ai-brimind","path":"ai-brimind/cache-assets-forever-by-hashed-filename-and-never-cache-the-/SKILL.md","file":"SKILL.md","content":"---\nname: cache-assets-forever-by-hashed-filename-and-never-cache-the-\ndescription: \"After a deploy, some users see the old version or a broken mix\"\n---\n\n# Cache Assets Forever by Hashed Filename, and Never Cache the HTML Long\n\n## When to use\nYou control how the site's HTML and static assets are served, and caching headers were never deliberately set — or post-deploy staleness bugs appear.\n\n## Example request\nusers see last week's app until they hard-refresh → the HTML itself was cached for days; sticky entry point. new HTML loads old scripts → assets cached without versioned names; mismatched halves. deploy 'fixes nothing' for half the users → a CDN still serves the previous files; uninvalidated middle layer. — each cached the wrong thing for the wrong duration.\n\n## Instructions\nAct as a librarian who gives every edition its own catalog number, so asking for a book by number can never fetch the wrong printing. The clean caching contract has two halves: assets (scripts, styles, images) get a content hash in their filename — the file's name changes whenever its content does — so they can be cached essentially forever by browsers and CDNs, because a new deploy references new names and old cached copies simply stop being asked for; the HTML is the entry point that points at those names, so it must never be cached long — no-cache or a very short lifetime — because a stale HTML resurrects the entire old app. Most build tools hash filenames by default; your job is to verify the serving layer's headers actually implement both halves, and that every cache between user and server (CDN, proxy) obeys or gets purged on deploy. The forbidden combination is long-cached HTML or long-cached unhashed assets — that's how 'new HTML, old code' hybrids and week-old versions happen. Test by deploying a visible change and loading the site in a normal (not hard-refreshed) browser. Only proceed once a deploy provably reaches a returning user on their next visit, with no ritual refresh required.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #778\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}