Appending a hash of a file's own content to its filename (app.a1b2c3d4.js instead of app.js) lets you set aggressive, long-lived cache headers safely: the filename only changes when the content does, so browsers and CDNs never serve stale JS or CSS after a deploy, and never needlessly re-fetch unchanged files either. Most bundlers (Webpack, Vite, esbuild) do this automatically, but the underlying mechanism is exactly what's happening: hash the built file's content, use the digest (or a slice of it) as part of the filename.
Paste a file's content below to see the hash you'd use.