Disabling Chrome cache for website development
I am modifying a site's appearance (CSS modifications) but can't see the result on Chrome because of annoying persistent cache. I tried Shift+refresh but it doesn't work.
How can I disable the cache temporarily or refresh the page in some way that I could see the changes?
Solution 1:
The Chrome DevTools can disable the cache.
-
Right-click and choose
Inspect Element
to open the DevTools. Or use one of the following keyboard shortcuts:
- F12
- Control+Shift+i
- Command+Shift+i
-
Click
Network
in the toolbar to open the network pane. -
Check the
Disable cache
checkbox at the top.
Keep in mind, as a tweet from @ChromiumDev stated, this setting is only active while the devtools are open.
Note that this will result in all resources being reloaded. Should you desire to disable the cache only for some resources, you can modify the HTTP header that your server sends alongside your files.
If you do not want to use the Disable cache
checkbox, a long press on the refresh button with the DevTools open will show a menu with the options to Hard Reload
or Empty Cache and Hard Reload
which should have a similar effect. Read about the difference between the options to know which option to choose. The following shortcuts are available:
- Command+Option+R on Mac
- Control+Shift+R on Windows or Linux
Solution 2:
Clearing the cache is too annoying when you need to clear the cache 30 times an hour.. so I installed a Chrome Extension called Classic Cache Killer that clears the cache on every page load.
Chrome Store Link (free) (Now without malware!)
Now my mock json, javascript, css, html and data refreshes every time on every page load.
I never have to worry if I need to clear my cache.
There are about 20 cache cleaners for Chrome I found, but this one seemed lightweight and zero effort. In an update, Cache Killer can now stay "always on".
Note: I do not know the plugin author in any way. I just found it useful.
Solution 3:
Pull up the Chrome developer console by pressing F12 and then (with the console open):
Right click (or hold left click) on the reload button at the top of the browser and select "Empty Cache and Hard Reload."
This will go beyond "Hard Reload" to empty the cache entirely, ensuring that anything downloaded via javascript or etc. will also avoid using the cache. You don't have to mess with settings or anything, it's a quick 1-shot solution.
Solution 4:
There are two more options to disable page caching in Chrome for good:
1. Deactivate Chrome Cache in the Registry
Open Registry (Start -> Command -> Regedit)
Search for: HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command
Change the part after ...chrom.exe" to this value: –disable-application-cache –media-cache-size=1 –disk-cache-size=1 — "%1"
Example: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -disable-application-cache –media-cache-size=1 –disk-cache-size=1 — "%1"
IMPORTANT:
there is a space and a hyphen after ...chrome.exe"
leave the path to chrome.exe as it is
If you copy the line, be sure to check, if the quotes are actual quotes.
2. Deactivate Chrome cache by changing the shortcut properties
Right-click on the Chrome icon and select "Properties" in the context menu.
Add following value to the path: –disk-cache-size=1
Example:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" –disk-cache-size=1
IMPORTANT:
there is a space and a hyphen after ...chrome.exe"
leave the path to chrome.exe as it is