Skip to content

FlashcardNot attempted

Why filenames carry a content hash

Recall it before you reveal

Why does a build emit index-BFP5p68h.js instead of index.js, and why is index.html never hashed?

Space to reveal
Show answer & explanation

The hash is computed from the file's contents. Same bytes → same name; one changed byte → a new name.

That makes "cache forever" safe: a URL like /assets/index-BFP5p68h.js can never point to different code, so browsers and CDNs may keep it for a year without checking. A deploy doesn't need to invalidate it: the new code simply has a new URL that no cache has seen.

index.html is the entry point people type and link to, so its URL must stay the same across deploys. It is the one file that changes in place, so it must be revalidated (no-cache), and it always points to the current hashed files.