1660

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?

Pang
  • 8,605
  • 144
  • 77
  • 113
tomermes
  • 21,672
  • 15
  • 39
  • 61
  • 194
    This is probably the single worst Chrome bug. I've wasted far too much time wondering why things were coming out wrong, only to find that--despite having forced a complete reload with ^F5--it's using an hour-old stale resource. – Glenn Maynard Jul 27 '12 at 16:58
  • 47
    Browsers are supposed to cache. Remember, your users will also be caching - and so may not see changes that you make after your site is in production. The way to avoid this is to version your files. my_css.css?version=something_unique. If the browser hasn't seen the version before then it downloads the file again. something_unique could, for example, be last modifed date. – user984003 Jan 30 '13 at 07:34
  • 36
    @user984003 `Ctrl+Shift+R` or `Shift+R` should flush the cache... – Adonis K. Kakoulidis Feb 03 '13 at 12:52
  • @user984003 Hi, can you elaborate a bit how to achieve that? Is it js or PHP? :) I'm very new in web development. – Boyang May 28 '13 at 04:13
  • 19
    @user984003 Not if I tell them to not cache. Yes, a cache-busting version number is great for final release as that's what users are using, but when I'm building a new site and I want to see incremental changes as I go, I'm not changing the version number each time. Hence why I develop with Firefox - it has the most reliable cache-disabling options! – andrewb Dec 17 '13 at 06:03
  • If I'm doing some heavy web testing/changes I usually just launch from the terminal (ubuntu): google-chrome --incognito You can throw other useful flags in there like --kiosk for fullscreen testing if that's a requirement. – Chris Trudeau Jul 15 '14 at 20:06
  • 11
    @user984003 yes, browsers are supposed to cache... when browsing. When developing, you need more control over that. – ahnbizcad May 04 '16 at 22:58
  • 4
    Browsers are not supposed to cache when you reload the page. That's why you reload the page. No other browser ignores that user request. – Mars Nov 28 '16 at 05:20
  • At least it wasn't just me who wasted hours trying to debug obsolete code due to cached content... – andreszs Apr 08 '17 at 20:57
  • It's really annoying. I always have the History tab opened and have to delete the cache after changing a .css or .js file. And get this - images keep getting cached even after that!! I have to use a file manager, go to the Cache and Media Cache and delete it manually to get a true reload of the images! – Zdenek Jun 17 '18 at 18:56

33 Answers33

2034

The Chrome DevTools can disable the cache.

  1. 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
  1. Click Network in the toolbar to open the network pane.
  2. Check the Disable cache checkbox at the top.

screenshot of development tools panel

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

long press

Steve
  • 24,693
  • 2
  • 31
  • 40
251

enter image description here

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.

dano
  • 5,440
  • 4
  • 24
  • 27
  • 4
    Yep, the Chrome Dev Tools option doesn't seem to work for me. But cache killer works like a charm. The reload time is significantly slower, like 4-5x, but the actual serving up of the new content is obviously much quicker. – Bryce Johnson Jan 24 '14 at 18:01
  • 3
    Clear Cache and Disable Cache are working only when working on localhost, on my mac. For online content I m refreshing and refreshing hoping to see any changes. This extension is a lifesaver. – Sbpro Feb 24 '14 at 17:31
  • 3
    I have found that using Disable Cache causes issues with local storage, specifically angular-storage with Auth0. Cache Killer works perfectly and does not cause issues with local storage. – trevorc Jan 12 '16 at 21:57
  • Didn't work well for me on Chrome. This caused side effects such as loading images twice I found and it was hard to locate the problem to this extension. – Martin Dawson May 09 '16 at 23:36
  • This incredible extension! It was a pain to work with angular js ngRoute. +1 – Programador Adagal Sep 27 '16 at 07:22
  • +1. Cache Killer has made my life better more than most things. However, on OSX (mac) it does not refresh the favicon appearing in the tab, unless CMD-R is use. I wonder why. – DanAllen Jan 29 '17 at 05:47
  • 1
    I think the plugin is removed from web store. How can I manually install it and any ideas why it was removed? – HasanG May 31 '17 at 12:52
  • 2
    Since the chrome store URL for CacheKiller is down, use this URL to download the CRX file, then drag the file into your chrome extension window to install it: https://www.crx4chrome.com/extensions/jpfbieopdmepaolggioebjmedmclkbap/ – BernieSF Jun 14 '17 at 15:20
  • 5
    Removed from Chrome Extensions Store because of malware :( Alternatives? – Semyon Vyskubov Oct 27 '17 at 07:49
  • 2
    The wonders of leddit https://www.reddit.com/r/webdev/comments/6d4tms/chrome_extension_cache_killer_gone/dp4uzz6/ just no clue about license etc so dunno if this sticks. – Jenne Nov 07 '17 at 09:07
  • 4
    Ended up writing my own, works the same but can toggle per tab. MIT License and no malware, I promise ! https://github.com/themichaelyang/cache-clearer – Michael Nov 11 '17 at 06:56
200

Picture of reload menu

  1. Pull up the Chrome developer console by pressing F12 and then (with the console open):

  2. 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.

JackArbiter
  • 5,435
  • 2
  • 24
  • 31
  • 7
    well it definitely doesn't work on mac though, I've clicked that reload button with various key-combinations ;) – MJB May 23 '14 at 12:59
  • @ManirajSS: It will reload everything and avoid using the cache, but it will not re-download things downloaded by javascript after page load. I'm not sure why anyone would ever use it, but I guess you could come up with a few corner cases where it would be useful. – JackArbiter Sep 12 '14 at 19:18
  • 2
    Nor will it clear cache for iframes inside of the page. – Pablo Mescher Oct 20 '14 at 17:49
  • 7
    Not sure how long this has been true, but as of Chrome 41, click and hold on the reload button works on OS X, provided you have the developer tools window open. – Tim Keating May 27 '15 at 02:31
48

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

danielson317
  • 2,684
  • 2
  • 18
  • 35
  • 3
    Good answer. Though for most people disabling the cache is just a temporary thing during development. Disabling it permanently will slow down a normal browsing experience significantly and is kind of bad internet citizenship as it puts unnecessary load on the web servers your visiting. – danielson317 Jun 26 '15 at 18:30
  • 3
    I don't agree with the bad internet citizenship thing, we're talking here about creating some shortcut for dev work. So this is definitely the best answer IMHO. Just a small thing. Every time I copy this on Windows from this SO page into some Chrome shortcut, some of the chars don't come out right. These are the right ones: `"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-application-cache --media-cache-size=1 --disk-cache-size=1` Also, what is the char right before `"%1"` ? That I don't know. – peter.petrov Sep 13 '18 at 16:35
33

If you do not wish to edit Chrome's settings you may use incognito mode for the same results.

basickarl
  • 25,903
  • 43
  • 172
  • 270
22
  1. F12 to open Chrome DevTools
  2. F1 to open DevTools Settings
  3. Check Disable cache (while DevTools is open) as shown below:

This is currently on the Preferences tab which is the default. You may need to scroll down. This checkbox has been moved at least a couple times since this question was asked. Last I checked, it was in the middle column at the bottom. If you have it open on a thinner screen and there are 2 columns under Preferences, it may be near the top right. Feel free to update this post if it changes or comment and I'll update the post.

enter image description here

Tony L.
  • 13,638
  • 8
  • 61
  • 63
22

In addition to the disable cache option (which you get to via a button in the lower right corner of the developer tools window -- Tools | Developer Tools, or Ctrl + Shift + I), on the network pane of the developer tools you can now right click and choose "Clear Cache" from the popup menu.

Andrea
  • 10,337
  • 17
  • 55
  • 59
Tim Keating
  • 5,636
  • 4
  • 41
  • 51
18

Instead of hitting "F5" Just hit:

"Ctrl + F5"

Arvand
  • 3,793
  • 3
  • 27
  • 36
17

In the Canary Channel (and maybe the dev and stable channel will follow along) this is to be found as the second option overall on the left hand-side under the "General" section.

Disable Cache in Chrome Canary Channel

In addition to that, there is always the option to switch into Incognito Mode via Ctrl + Shift + N. Even though that unfortunately also ends your session.

Bruiser
  • 11,357
  • 5
  • 31
  • 44
  • 4
    In my experience this only works while dev tools are opened. I was puzzled why the cache was still holding onto pages until I realized I had closed the dev tools. It is odd the setting doesn't override everything. – mbokil Jun 04 '13 at 00:12
  • Incognito mode does cache some images and files unfortunately. – GobSmack Aug 06 '15 at 20:16
16

Using Ctrl+Shift+R to refresh was nice but didn't get everything I needed. still some things wouldn't refresh, such as data stored in js and css. found a solution: a toolbar of google for chrome web developers. After you install the toolbar select options and "reset page".

n00begon
  • 3,467
  • 3
  • 26
  • 41
tomermes
  • 21,672
  • 15
  • 39
  • 61
  • 2
    +1. Still not perfect though: For developing on a local computer the cache is completely unneccessary and will introduce problems, so I would still be interested in a disable-feature like firebug has. – c089 May 18 '11 at 06:54
15

To be clear, the disable cache checkbox in Chrome (v17 here, but since v15 I believe) is not in the main settings UI. It is in the developer tools settings UI.

  1. From the browser window's wrench icon menu (prefs menu) choose Tools → Developer Tools

  2. In the developer tools UI that appears, click the gear icon at bottom right.

  3. Check the 'Disable cache' checkbox in the Network section.

Mason
  • 4,573
  • 3
  • 22
  • 23
14

Disable cache in chrome only works when you have dev tools open

jamiethepiper
  • 1,252
  • 1
  • 11
  • 17
  • maybe it is a bug or maybe it is only intended for developers - that said I would have thought non-developers would like to use the disable cache option too ¯\\_(ツ)_/¯ – jamiethepiper Jun 07 '13 at 10:36
14

Until the bug is fixed you could use Clear Cache Chrome plugin and you can also set a keyboard shortcut for it.

After installing it, right click and go to options:

enter image description here

Check Automatically reload active tab after clearing data:

enter image description here

Select Everything for Time Period:

enter image description here

And then you can go to Menu => Tools => Extensions:

enter image description here

Click on keyboard shortcuts at the bottom:

enter image description here

And set your keyboard shortcut, for example Ctrl + Shift +R:

enter image description here

Zoe
  • 23,712
  • 16
  • 99
  • 132
Răzvan Flavius Panda
  • 20,376
  • 13
  • 101
  • 153
9

Actually if you don't mind using the bandwidth it is more secure for multiple reasons to disable caching and advised by many security sites.

Chromium shouldn't be arrogant enough to make decisions and enforce settings on users.

You can disable the cache on UNIX with --disk-cache-dir=/dev/null.

As this is unexpected crashes may happen but if they do then that will clearly point to a more severe bug which should be fixed in any case.

8

This might help someone.

I have rigged my Nginx for crazy caching. Thus, disabling cache in network tools and explicitly clearing cache don't work.

A very simple yet boring workaround is, I just open a new Incognito Tab. Surprisingly it works, all the time!

A hard refresh in incognito mode does the trick anytime I wish to reload in the same mode.

KhoPhi
  • 7,701
  • 11
  • 70
  • 115
6

How about a bookmarklet which changes the page name to prevent the page from cacheing. In Chrome you would create a new bookmark and then paste the code into the URL. Click the bookmark and the page will reload with timestamp to thwart the cache.

javascript:(function(){var idx = location.href.indexOf('?');var d = new Date();var str = location.href.substr(0,idx) + '?version=' + d.getTime();location.href=str; void 0;})();
mbokil
  • 2,724
  • 23
  • 17
6

I just got caught out but not necessarily due to Chrome.

I am using jQuery to make AJAX requests. I had the cache attribute set to true in the request:

   $.ajax({
        type: 'GET',
        cache: true,
        ....

Setting this to false fixed my problem but this is not ideal.

I have no idea where this data is saved but I do know that chrome never hit the server for a request.

DynamicDan
  • 395
  • 3
  • 12
5

There is a better and quicker way now (Chrome version 59.x.x.):

Right-click onto the reload-icon (left of the url-field) and you get a drop-down menu, select the third option: 'empty Cache and Hard reload'.

This option is only available when the developer tools are open. (Notice the difference to option 2: 'Hard reload' -cmd-shift-R). No cache emptying here!

Luftwaffle
  • 181
  • 1
  • 3
3

There is a chrome extension available in the chrome web store named Clear Cache.

I use it every day and its a very useful tool I think. You can use it as a reload button and can clear the cache and if you like also cookies, locale storage, form data etc. Also you can define on which domain this happens. So can clear all this shit with only the reload button which you anyway have to press - on your chosen domains.

Very very nice!

You also can define a Keyboard Shortcut for this in the options!

Also another way is to start your chrome window in incognito-mode. Here the cache also should be completely disabled.

chris
  • 4,555
  • 5
  • 30
  • 53
  • Can't find the option to define on which domain it does it. Doesn't look very good. How about https://chrome.google.com/webstore/detail/cache-killer/jpfbieopdmepaolggioebjmedmclkbap/ ..? – nkkollaw Apr 26 '13 at 08:14
  • go to clearcache icon in the browser, rightclick, options and then under cookies. There is a little settings icon. – chris Apr 26 '13 at 12:57
2

One more option for disabling the cache is provided by my 3rd Chrome extension Page Size Inspector that disables the cache exactly the same way as Devtools does.

In addition, the extension quickly reports page size, cache usage, network requests and load time of a web page in a convenient way. Plus its open source at Github.

Screenshot - Page Size Inspector

Tomi Mickelsson
  • 179
  • 2
  • 2
2

Not sure what you are using, but if you are using ASP.Net you can do the following which works like a charm:

<link href="@Url.Content("~/Content/Site.css")?time=@DateTime.Now" rel="stylesheet" />

Basically it will automatically append the Date and Time to the end of the file each time it is ran, meaning since the file name is technically different, you will never have to worry about it getting cached again.

MattE
  • 906
  • 10
  • 23
  • absolutely. I used this, and conditional compilation, so it does not appear in test and release builds. – Cee McSharpface Feb 17 '17 at 19:48
  • Even better way is to use css files modification time as a variable value. That solution can be used in production environment also. It just works :) Not sure how it's done in ASP but in PHP something like this – Oliver Manner Oct 30 '17 at 08:32
2

I had the same problem, I tried :

  • Control Shift R,
  • Disable cache in F12
  • Control F5.

Then I discovered that using a .appcache manifest for a non https site is deprecated. I removed my site.appcache file and its reference in the html tag and now I'm seeing the latest version of each page!

Ole EH Dufour
  • 2,187
  • 1
  • 20
  • 33
2

If you're using ServiceWorkers (e.g.: for Progressive web apps), you'll likely need to check "Update on reload" under Application > Service Workers in dev tools too.

enter image description here

Samuel Liew
  • 68,352
  • 105
  • 140
  • 225
Bob
  • 1,295
  • 14
  • 22
2

When this question was asked, Chrome didn't support the Disable Cache feature. But now, you can find the "Disable Cache" feature in Network Tab in Chrome Dev Tools.

Network Tab with Cache Disabled

Screenshot - Disable Cache Feature in Chrome Dev Tools

You can see that all the resources (I have filtered JS resources) have been fetched from network and not loaded from disk/memory cache.

Disable Cache not selected

enter image description here

You can see that when I refreshed the page but didn't select the "Disable Cache" feature, almost all the resources were loaded from Cache.

This works fine for local web development but there are certain limitations that I'd like to highlight. You can stop reading here if the solution discussed so far meets your use case.

Limitations

  1. You have to keep the DevTools Open and Disable Cache Selected
  2. When you disable the cache, it is disabled for all the resources in that tab. It makes things slow and is inefficient if you want to disable cache for only 1-2 resources

Using Requestly Chrome Extension to disable Cache for particular resources (JS/CSS/Images, etc)

Recently, I stumbled upon https://dev.to/requestlyio/disable-caching-of-particular-js-css-file-2k82 which helped me understand how you can disable cache for specific resources.

The trick here is to add a query parameter to your resource with random value every time the request is made. Using Requestly Query Param Rule, you can add a param like this

URL Contains mywebsite.com/myresource.js
Add param cb rq_rand(4)

rq_rand(4) is replaced by 4 digits random number when a request is made.

Requestly Query Parameter Rule to add random parameter

enter image description here

After adding the rule, JS/CSS files are not cached

Requestly Rule applied and added a random parameter to disable cache

Here you can see that "Disable Cache" is not selected and still the resources are not loaded from Cache because of a random parameter (cb - Read it as Cache buster) in the URL.

  1. The good thing is you don't need to keep your dev tools open for having this behavior
  2. You can keep this permanently ON and your browsing experience won't be affected too.

How to get the Rule

Here is the link using which you can browse & download the rule if you have Requestly installed - https://app.requestly.io/rules/#sharedList/1600501411585-disable-cache-stackoverflow

Disclaimer: I built Requestly but I think this could be helpful to a lot of web developers and hence sharing here.

sachinjain024
  • 19,669
  • 27
  • 88
  • 154
1

Since version 50 (if I remember correctly), the "Disable cache" option was removed from the Devtool Settings. Go to the "Network" tab and there's the "Disable cache" option.

Pang
  • 8,605
  • 144
  • 77
  • 113
boi_echos
  • 1,659
  • 3
  • 21
  • 38
0

Hey if your site is using PHP then place following little PHP snippet at the beginning of your html page :

   //dev versioning - stop caching
   $rand = rand(1, 99999999);

Now everywhere you load resources like CSS- or JS- files in a script or link element you append your generated random value to the request URL after appending '?' to the URI via PHP:

    echo $rand;

Thats it! There will be no browser that caches you site anymore - regardless which kind.

Of course remove your code before publishing or simply set $rand to an empty string to allow caching again.

Torsten Barthel
  • 2,022
  • 19
  • 19
0

I have used the other options described above but I find that the best is to add the following parameter to the startup of chrome.exe.

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disk-cache-size=1 -media-cache=1

I find not disabling media cache is a good idea but it is here for completeness sake.

In actuality I want an option to completely disable the cache, to use the memory for IO instead of my disk (which would make load time 10x faster too!) but I don't think chrome or any browser for that matter has that option yet.

Ahmed
  • 205
  • 2
  • 13
0

How can I disable the cache temporarily or refresh the page in some way that I could see the changes?

It's unclear which "cache" you're referring to. There are several different methods a browser can cache content persistently. Web Storage being one of them, Cache-Control being another.

Some browsers also have a Cache, used in conjunction with Service Workers, to create Progressive Web Apps (PWAs) providing offline support.

To clear the cache for a PWA

self.caches.keys().then(keys => { keys.forEach(key => console.log(key)) })

to list the names of the cache keys, then run:

self.caches.delete('my-site-cache')

to delete a cache key by name (i.e., my-site-cache). Then refresh the page.

If you see any worker-related errors in the console after refreshing, you may also need to unregister the registered workers:

navigator.serviceWorker.getRegistrations()
  .then(registrations => {
    registrations.forEach(registration => {
      registration.unregister()
    }) 
  })
Josh Habdas
  • 6,370
  • 2
  • 53
  • 55
0

Chrome's Cache killer is by far the best option. Since the store URL to install cache killer is down, you can download the CRX file here:

https://www.crx4chrome.com/extensions/jpfbieopdmepaolggioebjmedmclkbap/

once the extension file is downloaded, open Chrome -> more tools -> extensions, then drag the CRX file from the File Explorer or your Desktop (depending the location where you downloaded the file) into the chrome window to install the extension.

BernieSF
  • 1,318
  • 1
  • 23
  • 40
0

I was in a situation that the browser load the cache data from disk even I checked it disabled cache (I was using Chrome). All my CSS and JS were loading from server but not the web page. This was happening on both my local and Production.

To fixed it, I need to put an extra param in my URL to force the browser to get the web page from server, even the controller did not need it.

I was using ASP.Net, so here is my example :

//Controller function
public ActionResult Index()
    {
        return View();
    }
//Link
@Html.Action("Index", "Home", new { ts = DateTime.Now.Ticks.ToString()})

The result is, it will generate a link like: http://www.myweb.com/Home/Index?ts=636558555408282209

This is my situation and solution. Hopefully it could help somebody.

Tam
  • 3,153
  • 3
  • 30
  • 50
Jansen
  • 139
  • 1
  • 3
0

I use (in windows), ctrl + shift + delete and when the chrome dialog comes up, press enter key. This can be configured with what needs to be cleared each time you execute this sequence. No need to have dev. tools open in this case.

santon
  • 1,442
  • 14
  • 25
0

The problem with "annoying" cache in general layes in the framework :). Let's see details. Most of frameworks uses in .htaccess (os equivalnent) derective redirecting all requests to frameworks "index",

BUT it the same time EXCLUDE files and directories requested by application directly.

(f.e. as for .htaccess typical directives are:

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

)

Thus ALL .js, .css files as graphics ones are not handled by frameworks "index".

And those files are generally most often changed during development.

That's why the cache control derective should not be placed in frameworks "index".

It should be palced in .htaccess.

F.e. for development process use:

  Header set Cache-Control "no-store, no-cache, must-revalidate"
  Header set Pragma "no-cache"

(Or for consecutive working versions, use "Etag" directive - check more in HTTP reference. Notice, that ETag is not intended for development.

In .htaccess there is no direct way to generate random number (or fast changing sequence like date UTC) to use in ETag, because - as I mentioned before - this is not what this is provided for).

Hope it helps and saves time.

Marek Wysmułek
  • 196
  • 1
  • 5
-1

Add this string of code to your and it should do the trick.

<meta name="robots" content="noarchive">
Hossein Hajizadeh
  • 1,029
  • 15
  • 9