Using Chrome DevTools, how do you track down an API call that fails only for returning users with cached assets and never reproduces with your DevTools open?
answer
- what did you leave ticked?
- reload without clearing anything
- the Size column says where it came from
- walk back from call to script
- a worker is a different cache
basics
~20 sDisable cache probably hides the failure: untick it, reload as a returning visitor, read each script's source in the Size column, follow the failing call's Initiator tab back to that script, and compare its call with the current build.
solid answer
~50 sMy first suspect is my own setup: **Disable cache** applies only while DevTools is open, so with it ticked I never see what a returning user sees. I untick it, tick **Keep log**, load the page once to fill the cache, then reload normally. The **Size** column shows `(disk cache)`, `(memory cache)` or `(ServiceWorker)`, and `is:from-cache` lists the cached responses. On the failing call, the **Initiator** tab shows the request call stack and initiator chain, which leads back to the script that fired it, and I check whether that script came from the cache and is an older build. I compare the URL and Payload with a working call. Ticking Disable cache again, or using **Clear browser cache**, should make the failure disappear, which confirms the theory. If Size says `(ServiceWorker)`, I test with **Bypass for network** instead.
go deeper
Recall that Disable cache applies only while DevTools is open and that the Size column shows whether a file came from the network or a cache.
Explain how the Initiator tab's call stack and chain lead from a failing request to the script that fired it, and how is:from-cache and the Size column show where that script came from.
Start by doubting your own setup, reproduce the returning visitor deliberately, and prove the link between cached script and failing call by changing one variable at a time. Know that a service worker needs a different switch.
Treat the bug class as a release concern: any API change that an old cached client cannot handle will reach users, so deciding how long old bundles must keep working belongs in the deployment plan.
## The symptom points at your own tools A call that fails for returning visitors but works for you, and only ever with DevTools open, has a very likely cause: you are not running what they are running. Their browser reuses scripts it fetched earlier, while yours has been re-fetching everything since you ticked a box months ago. The box is **Disable cache** in the Chrome DevTools Network panel toolbar. Its tooltip spells out the rule: *Disable cache while DevTools is open*. Three properties matter: - **It bypasses the browser cache** for as long as DevTools is open on the page, so every load behaves like a first visit. - **It does not delete anything.** Entries are still there and get used again once DevTools closes. Deleting is a different command, **Clear browser cache**, in the right-click menu of the request list. - **It is a remembered setting.** Tick it once and it stays ticked next time, which is how it becomes invisible. Many developers leave it on permanently and forget that they are testing a state no returning user is ever in. ## Reproducing the returning visitor 1. Untick **Disable cache** and tick **Keep log**, so that a redirect or reload does not clear your evidence. 2. Load the page once, normally, so the browser has something cached. 3. Reload normally rather than with a hard reload, which refetches resources and defeats the purpose. 4. Trigger the failing action and find the red row. If your freshly cached files are from the current build, this may still pass, because the affected users hold an older build. Reproducing that needs an older cached copy, or a HAR from one of those users. The panel shows initiators for imported HAR requests, so the same reading works on their file. ## Reading where each asset came from The **Size** column says where a response came from, which makes it the key column for this bug. | Size column shows | Meaning | |---|---| | A byte count | Fetched from the network | | `(disk cache)` | Served from the browser's disk cache | | `(memory cache)` | Served from the browser's in-memory cache | | `(ServiceWorker)` | Fulfilled by a service worker | | `(prefetch cache)` | Served from a prefetch | The filter term `is:from-cache` lists cached responses, and `is:service-worker-intercepted` lists responses a worker fulfilled. The opposite form, `-is:from-cache`, shows what really went to the network. ## Walking back from the failing call The call itself is often fine as far as the network goes; what matters is which code sent it. Three views of the **initiator** help: - **The Initiator column** names the script and line, or says `Parser`, `Redirect` or `Preload`, and links to the source. - **The Initiator tab** on the row shows the **Request call stack**, the functions that led to the call, and the **Request initiator chain**, the tree of requests that led to this one: document, then script, then fetch. - **Holding Shift while hovering a row** colours its initiators green and its dependents red across the request list, which shows the chain without opening a tab. Follow the chain to the script, then read that script's row. If its Size says `(disk cache)` and its filename or content belongs to a previous build, you have your explanation: an old bundle is calling an API in a shape the new server rejects. ## Confirming the theory Compare the failing call with a working one in the **Headers** and **Payload** tabs, looking at the URL, the parameters and any version header. Then flip one variable at a time: - **Tick Disable cache and reload.** If the failure vanishes, cached assets are involved. - **Copy both versions as cURL** and run them. If the failing shape is rejected outside the browser too, the server is answering that shape consistently, so the mismatch is the likely cause. ## When the cache is a service worker If Size shows `(ServiceWorker)`, Disable cache is not the right switch. A worker's Cache Storage is separate from the browser cache that checkbox bypasses, so a worker can keep serving an old script with the box ticked. Use **Bypass for network** in the Application panel's service worker section to send requests straight to the network, and see if the failure disappears. Why the file stayed cached, and which headers should govern that, is a question about HTTP caching policy and the release process. The Network panel's job ends once you have shown which cached file made which call.
- How can you reproduce this if your cache only ever holds the current build?You need the older asset. Ask an affected user for a HAR, since it preserves initiators and the failing request's shape. Or use **Override content** on the script to serve a saved older copy from a local folder, then reload. That recreates the mismatch without touching the deployed build or waiting for a cached copy to age.
- What is the difference between Disable cache and Clear browser cache in the Network panel?**Disable cache** bypasses the cache only while DevTools is open, and the entries survive for later. **Clear browser cache**, in the request list's right-click menu, deletes the entries, so the next load starts empty even after DevTools closes. Clearing also removes the very state you may be trying to reproduce, so do it last.
Testing with Disable cache is like a shop manager who always fetches stock straight from the warehouse while on the floor: the shelves still hold last season's goods, and every customer who comes in after the manager leaves takes from those shelves.
- Believes ticking Disable cache deletes the cached files from the browser.
- Assumes Disable cache stays in force after DevTools is closed.
- Says Disable cache also makes a service worker skip its Cache Storage.
- Leaves Disable cache ticked permanently and calls that a returning user's experience.
- Clears the cache first and destroys the state being investigated.
- Debugs the failing call's server code before finding which script sent it.