Users see the old site? Check caching

You published a fix an hour ago. It looks right on your laptop. But a customer emails a screenshot of the old page, with the old bug, and a friend on their phone sees last week's pricing. The server is fine. The visitor's browser, or something between them and your host, is holding an old copy.

The symptom

  • Some visitors see the new version and others see the old one, and it doesn't depend on which page they open.
  • A hard refresh or a private window shows the new version, but a normal visit doesn't.
  • The old version keeps coming back even after the visitor refreshes once.
  • Sometimes the old page loads and then breaks, because it asks for script files that no longer exist on the server.

The cause

There are two usual suspects, and they can stack on top of each other.

A service worker. This is a small script a site can install in the browser to make it load fast or work offline. If you ever added a PWA plugin, asked your builder for "offline support" or "installable on the home screen", or copied a template that had one, your site may register a service worker. It caches your pages and files, then serves them from the cache on the next visit. If it isn't set up to update itself, a visitor can stay on an old build for days.

Cache headers on your HTML. Your host or a CDN in front of it can tell browsers to keep index.html for hours. Script and style files with a hash in their name are safe to cache for a long time, because every build gets new names. The HTML page that points to them is not. If the HTML is cached, the browser keeps loading the old file names.

Step-by-step diagnosis

  1. Open your live site in a normal window. Open DevTools, go to the Application tab, and click Service Workers. If one is listed for your domain, note its status and the script name, often sw.js or service-worker.js.
  2. In the Network tab, make sure "Disable cache" is unticked, reload, and click the first document request. If the Size column says "(ServiceWorker)", the page came from the worker, not your host.
  3. Look at the response headers for that document. Find Cache-Control. A value like max-age=3600 or s-maxage=86400 on HTML means browsers or the CDN can keep it that long.
  4. Run curl -sI https://yourdomain.com/ from a terminal. Check Cache-Control, Age and any CDN cache header such as cf-cache-status or x-vercel-cache. A large Age with a HIT means the CDN is serving an old copy.
  5. Search your project for serviceWorker.register, vite-plugin-pwa or workbox. That tells you whether your own code installs a worker.

Fixes per builder or host

Lovable and Bolt (Vite projects)

If vite-plugin-pwa is in the project and you don't need offline mode, ask the builder to remove it and to ship a small "kill switch" worker at the same path that unregisters itself and clears its caches. Simply deleting the file isn't enough: browsers that already installed the worker keep using it until a new version at that path tells them otherwise. If you do want offline mode, set the plugin to registerType: 'autoUpdate' so new builds take over on the next visit.

v0 and other Vercel deploys

Vercel serves HTML without long browser caching by default. If you added custom headers in vercel.json or next.config, make sure the long max-age applies only to hashed files under your static folder, not to every route. Redeploying purges Vercel's edge cache.

Replit deployments and Netlify

Check any _headers file, netlify.toml or server code that sets Cache-Control. For HTML use no-cache, which lets the browser keep a copy but forces it to check with the server first.

Cursor projects behind Cloudflare

If a Cloudflare rule caches everything, exclude HTML or add a purge step after each deploy. "Cache Everything" with a long edge TTL is the most common reason a fresh deploy stays invisible.

How to verify

  • Change one visible word, deploy, and open the site in a normal window on a second device you used before the fix. It should show the new word within one reload.
  • In DevTools, the Service Workers panel should be empty, or show your new worker as activated.
  • The document's Cache-Control should say no-cache or a very short max-age, while hashed scripts can stay long.

Prevention

  • Only add a service worker if you really need offline mode, and always pair it with an update strategy.
  • Keep one rule in mind: HTML is never cached for long, hashed files can be cached for a year.
  • After every deploy, check the live page from a device that visited before, not just your editor preview.

A stale cache is hard to spot from your own desk, because your browser usually has the newest copy. Checking the live site the way a returning visitor sees it is the fastest way to catch it.

Run the free 30-second check

Run the free 30-second check

← All posts

FlowCanary on SaaSHub