I'm trying to test the behaviour of my site on the assumption that the local disk cache is empty. I know that there are ways of clearing the cache and doing Ctrl-F5 etc each time, but there is also a "Disable Cache" checkbox in the Network tab that seems like it should do what I'm after... i.e. disable the cache.
But, when I clear the cache, enable that option, and F5-reload my site a couple of times, this is what I see:
The resource has been cached, and is being served from cache, despite "disable cache" being enabled! So what does this option actually do?
EDIT
Maybe this behaviour I'm seeing relates only to caching of service worker scripts? If you load this page (an example linked from this guide to service workers), at least for me the sw.js
file is fetched from disk cache even with "disable cache" enabled.
Along the top of the network panel, there's a checkbox that says “Disable Caching.” This disables browser-level caching, but only as long as the DevTools are open. So it won't affect your normal browsing, but while working with the developer tools you won't have to worry about stale content.
To open Developer Tools, press the F12 key or Ctrl+Shift+I keys on the keyboard. You can also open the main menu at the top-right corner and select Developer Tools from the More Tools side menu. Here move to the Network tab and check the checkbox next to the Disable cache option.
Like other web browsers, Google Chrome features a cache that stores files such as images, scripts and video content from websites that you visit over time.
Open the developer tools window in Google Chrome. You can do this by opening the three-dot menu in the top-right corner, hovering over "More Tools" and selecting "Developer Tools." Ignoring the new window, right click the Refresh button in your browser window. Choose the final option – "Empty Cache and Hard Reload."
Interesting question!
In the screenshot you've provided, the Name column is cut off, so I can't tell what resource is still being served from disk cache. I'll assume that it's a service worker script, based on the description in your "EDIT".
The question I'll answer, then, is "how does the browser cache service worker (SW) scripts?"
importScripts()
, those scripts are also stored in the SW database. Also note that when a service worker script gets updated, the browser overwrites the currently-stored script in the SW database with the new script. This is the Chrome implementation, other browsers may do it differently. 1
(from disk cache)
. Ideally, it should have some other name to indicate that this cache isn't affected by the Disable Cache checkbox.So, in this case, you're right: the Disable cache checkbox does nothing. If you want to ensure that your cache is completely cleared (including service worker stuff):
While DevTools is still open, long-press Chrome's Reload button, and select Empty Cache and Hard Reload. See https://stackoverflow.com/a/14969509/1669860 for an explanation of these different options.
1 I got this info from Alex Russell, Chrome engineer and co-author of the service worker spec
In addition to the disable cache option, on the network pane of the developer tools you can now right click and choose "Clear Cache" from the popup menu.
Also, you can use this plugin if you need to clear the cache frequently: https://chrome.google.com/webstore/detail/jpfbieopdmepaolggioebjmedmclkbap
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With