Learning center

Users still see the old version after a deploy: find which cache answered

When users see the previous release after a deploy, the browser cache, a service worker or a CDN is answering. Each leaves a different mark in the Network panel and needs a different fix.

Three caches, three marks#

CacheWhere it livesMark in Chrome's Network panelTypical cause
Browser HTTP cacheThe user's browserSize column shows (disk cache) or (memory cache); no request reaches the serverThe HTML was sent with a long max-age, or with no Cache-Control, so the browser applied heuristic freshness
Service workerThe user's browser, in the site's scopeSize column shows (ServiceWorker); the Timing tab shows service worker phasesThe worker serves a cached page and the new worker is waiting to activate
CDN or proxyBetween the user and the originA normal network response with an Age header above zero, or a vendor header such as cf-cache-status: HITThe CDN cached the HTML, and the deploy did not purge or revalidate it

Network timing phases · Age header in HTTP caching · Cloudflare cache status values

The page that matters is the HTML document. Hashed asset files such as app.3f9c1a.js can be cached for a long time, because a new release gives them new names. The HTML names those files, so a stale HTML document keeps loading the old ones.

First, know which version you are looking at#

You need a way to tell versions apart before you can say a user has the old one. Use something the release changes:

  • a build identifier the app prints in the page, a meta tag or a /version endpoint;
  • the hashed name of the main script in the HTML, read from the document's Response tab;
  • a release header the server adds to the document response.

Then fetch the HTML from outside the browser, which skips the browser's caches and the service worker:

curl -s https://app.example.test/ | grep -o 'assets/index-[a-z0-9]*\.js'
curl -sI https://app.example.test/ | grep -iE '^(age|cache-control|etag|cf-cache-status|x-cache):'

If curl also gets the old name, the CDN or the origin still serves it. If curl gets the new name and the browser the old one, suspect the browser, but do not conclude yet: your curl may reach a different CDN location from the affected user. The affected browser's own document request, below, decides which cache answered.

Separate the browser caches#

In the browser that shows the old version, open DevTools, keep Preserve log on and reload. Select the document request.

(ServiceWorker) in the Size column means the service worker answered. Open Application > Service workers. A new worker shown as waiting to activate is the usual reason: an updated worker waits until no tab is controlled by the old one, and a reload alone does not free the tab, because the old and new page overlap during a refresh. Closing every tab of the site, or code that calls skipWaiting(), lets it take over. Service worker lifecycle · Debugging service workers in DevTools

(disk cache) or (memory cache) means the browser reused a stored response without asking the server. Read the cached response's Cache-Control. HTML with max-age=86400 can stay for a day. For HTML, no-cache makes the browser revalidate with the server before each use. MDN: HTTP caching

A normal network response means neither browser cache answered. Read that response's Age and the CDN's cache status header: this is what the CDN served to this user, which your own curl does not show.

To confirm, tick both Bypass for network under the service worker and Disable cache in the Network panel, then reload, because each bypasses only one of the two browser caches. Check that the document row now shows a normal network response. If the new version appears, a browser cache served the old one; untick the two options one at a time to see which. If the old version still appears in a normal network response, the browser was not the cause; the CDN or the origin served it to this browser.

Worked example: half the support team sees the old release#

This example is fictional. A support tool released version 41 at 09:00. By 11:00, three of eight support agents still saw version 40, judged by the footer's build number.

The document request on an affected machine showed (ServiceWorker). The Application panel showed version 41's worker as waiting to activate. Every affected agent kept the tool open in several tabs all day; the unaffected ones had closed and reopened the browser. Ticking Bypass for network and reloading showed version 41, with its script name in a normal network response. The service worker had answered, and the CDN served the new release to that machine. curl from a laptop also returned version 41's script name, but that alone would not have cleared the CDN, because the laptop could reach a different CDN location.

The report said: the version 41 service worker installed but is waiting, because agents keep a tab of the tool open. The old worker serves version 40's cached HTML. Closing all tabs of the tool fixes one machine. The fix in code was to prompt the user to reload when a new worker is waiting, and to activate it then.

What to put in the report#

  • How you identified each version, and which one the user had.
  • The document request's Size column value and its caching headers.
  • The service worker's status in the Application panel, if one is registered.
  • The Age and CDN headers of the affected browser's document response, when it came from the network.
  • The curl result for the same URL, with its Age and CDN headers, and the time, as a comparison.
  • Which change made the new version appear: closing tabs, bypassing the worker, disabling the cache, or nothing.

Questions#

Why does a hard reload show the new version, but the next normal load shows the old one?

A force reload (Shift with reload) skips the HTTP cache and leaves the page uncontrolled by the service worker for that one load. The next normal load goes through the waiting-or-active worker again. That pattern points at the service worker. Shift-reload and service workers

The CDN shows a cache hit for the HTML. Is that wrong?

Not always. Some sites cache HTML at the edge for a short time and purge on deploy. Compare the response's Age with the time since the deploy: an Age older than the deploy means the purge did not reach that object.

Why do only some users see the old version?

Each user's browser holds its own caches, and each CDN location can hold its own copy. Users who loaded the page recently, or whose region cached it before the deploy, see the old copy for longer. Record the user's location and when they last loaded the page.

Return to the method for browser bug reports for the other symptoms in this collection.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading