Build Artifacts and Cache Busting

Know which files you actually ship, which settings become public, and how browsers cache them, then test the exact files you release.

Content date: October 15, 2026.

Plain English

Your source files, your development server, and your production build are three different things. A framework compiles, bundles, renames, or copies your files into an output folder, and that output is what browsers receive, not your source folder. A successful build only shows that the build command finished. It does not show that pages load, settings are right, private data stays out, or users can finish their tasks.

Use this when

Check this before your first preview deployment. Check it again whenever you change build tools, dependencies, file paths, public settings, or caching rules.

If you are just starting

Find the project's production build command and its output folder (often called dist or build). Write down the source version, the Node and package manager versions, the lockfile, any public settings, and the files the build produced. Preview the built output, not the development page, and check that the entry page and every file it points to actually load. The free practice uses a single self-contained form, where copying the file counts as a simple build. That is not the same as a framework bundler.

When your project grows

Keep the inputs reproducible and look at what comes out. In Vite, any variable starting with VITE_ is bundled into the browser code, so it can never hold a secret, and changing one means rebuilding. Decide on purpose who can get source maps (files that reveal your original code). Give built files a content hash in the name, such as app.3f9a1c.js, and cache them for a long time with Cache-Control: public, max-age=31536000, immutable. Serve the HTML entry page with no-cache so browsers always check for the newest version, which points to the new hashed files. Keep older files as long as open browsers and rollbacks may ask for them. Where your host allows it, promote the build you already checked, and test any per-environment rebuild separately.

Worked example

In the local practice, the script copies a contact form into baseline.html and records its SHA-256 checksum (a fingerprint of the exact bytes). Changing a heading makes a second file with a different checksum. If someone swaps in a different file after checking, the release fails its identity check. This shows byte-for-byte identity for one simple file. It does not show how a bundler behaves, and it does not prove every checked byte is safe.

Practice

Trace source to a checked artifact

  1. Run the local release practice and look at its baseline, second-release, and report files.
  2. Run it again from a separate folder with the same source file and compare the baseline checksums.
  3. For your own project, write down the build command, the Node version and lockfile, the public settings, the output paths, and whether source maps are published.
  4. Open the built output, check the files it references, and test it directly rather than relying on the development page.
  5. Write one cache rule for the HTML page and another for hashed files, including how long you keep old files, and note anything you could not test on your host.

Deliverable: A short manifest of your build with its observed checksums, inputs, checks, and limits, plus your written cache rules.

Common mistakes to watch for

  • The development server hides a broken file path that only appears in the production build.
  • A payment or AI key put in a VITE_ variable ends up readable in public JavaScript.
  • A file that changes often, such as the HTML page, is cached for a year, so visitors never see updates.
  • Old script files are deleted at deploy time while customers still have the site open, and their next click fails.
  • A matching checksum is treated as proof that the build is safe.

Prompting

A weak prompt

The dev page works, so just upload the folder and cache everything forever.

A better prompt

Tell me this project's production build command, locked dependencies, Node version, output folder, public settings, and whether source maps get published. Build it, inspect the real output, and preview it. Propose cache rules for the HTML page versus hashed assets, including keeping old files for open browsers and rollbacks. Record a checksum of what we checked and flag any per-environment rebuild. Do not treat a finished build as proof of correct behavior or safety.

Customers get the built files, not the ones you tested in development, so only checking the build output tells you what they will actually see.

Check before you move on

  • The production build command and output folder are known.
  • The versions and lockfile used are written down.
  • Anything beginning with VITE_ is treated as public.
  • The built page's file references were checked.
  • HTML and hashed files have different cache rules.
  • A checksum is understood as identity, not as proof that the page works.

You are done when

  • You can say which exact files were checked and whether deploying changes them.
  • Your notes separate local file copying, a framework build, and behavior on a real host.

Questions to think about

A friend puts a private payment key in a VITE_ variable so the website can use it. Is it safe?

No. Vite bundles VITE_ values into the code that every visitor downloads, so anyone can read it. Keep secrets on a server that visitors cannot see into.

Two builds have the same SHA-256 checksum. Does that prove the page works?

No. It only proves the files are byte-for-byte identical, so a broken page still has an identical checksum. Behavior and security need their own tests.

After a new release, why keep last week's hashed JavaScript file on the server?

Someone who opened your site before the release may still request it, and a rollback may need it too. Deleting it immediately can break those visitors' next click.

Official references