Is there a way to clear the cache for a particular domain

36,381 views
Skip to first unread message

Jianwei Sun

unread,
Oct 14, 2011, 9:44:48 AM10/14/11
to google-chrome-...@googlegroups.com
When I edit a javascript file in visual studio, and try to debug. The chrome is still using the old version of javascript file. Is there a way to clear the cache for the current domain to force to load the updated file.

Thanks,
J.W.

PhistucK

unread,
Oct 14, 2011, 10:29:38 AM10/14/11
to google-chrome-...@googlegroups.com
Are you asking that while knowing that there is a general no cache option?
If so, I do not think there is a per domain no cache option.
If not, go to the Developer Tools, click on the cog wheel at the bottom right corner and check "Disable cache" under "Network".

PhistucK

Steven Holms

unread,
Oct 16, 2011, 5:07:18 AM10/16/11
to google-chrome-...@googlegroups.com
Don't know if this is what you mean, but you could do a clear refresh (ctrl+f5). That's what I use to clear the cache for the current page I'm on.

Tim Meadowcroft

unread,
Oct 16, 2011, 9:03:05 AM10/16/11
to google-chrome-...@googlegroups.com
The 'clear cache' option was added because people complained that, when using Developer Tools, F5 and Ctrl-F5 don't always work reliably (esp for dynamically loaded content).

See http://code.google.com/p/chromium/issues/detail?id=8742 for a long trail of complaints etc - it seems the fix that closed the issue is the addition of the disable-cache and clear-cache features, not an improvement to Ctrl-F5.

In there you'll also see (around comment #33) that some of us found that closing the Chrome tab and opening the page in a fresh tab did much better at clearing the cache, so I wrote a small Chrome extension ("Force Reload") to map Ctrl-F5 to do just that 


If Ctrl-F5 works fine for you as is, no problems, and if you don't mind clearing the cache within devtools, you can do that too, but the extension is also pretty handy IMHO :)

--
T


Vsevolod Vlasov

unread,
Oct 17, 2011, 2:41:35 PM10/17/11
to google-chrome-...@googlegroups.com
To summarize the options that are available to you:

1. Use version suffixes like script.js?42 -- this is usually used on production
2. Set up your web server to serve scripts with no-cache headers -- this way you can get caching control from the server side.
3. Clear cache using either browser menu or Developer Tools Network Panel context menu - unfortunately you can not clear cache only for certain domains.
4. Disable cache from Developer Tools settings -- this will only work while Developer Tools front-end is opened. 
5. If you are not loading scripts dynamically then Ctrl+R/Ctrl+Shift+R could work as well.

John J Barton

unread,
Oct 17, 2011, 3:03:32 PM10/17/11
to Vsevolod Vlasov, google-chrome-...@googlegroups.com
On Mon, Oct 17, 2011 at 11:41 AM, Vsevolod Vlasov <vse...@chromium.org> wrote:
To summarize the options that are available to you:

1. Use version suffixes like script.js?42 -- this is usually used on production
2. Set up your web server to serve scripts with no-cache headers -- this way you can get caching control from the server side.
3. Clear cache using either browser menu or Developer Tools Network Panel context menu - unfortunately you can not clear cache only for certain domains.
4. Disable cache from Developer Tools settings -- this will only work while Developer Tools front-end is opened. 
5. If you are not loading scripts dynamically then Ctrl+R/Ctrl+Shift+R could work as well.

Just to point out: everyone that uses require.js or dojo, etc. is using dynamic scripts whether they realize it or not. 

I don't have a test case but I believe Developer Tools some how interferes with Ctrl+R/Ctrl_Shift+R. I have to Ctrl+W Web Inspector, reload, then open Web Inspector again.  Does anyone else see this?

jjb
 

Vsevolod Vlasov

unread,
Oct 17, 2011, 5:07:12 PM10/17/11
to John J Barton, google-chrome-...@googlegroups.com
Web Inspector should not interfere with dynamic script loading. But cache related behaviour is somewhat nondeterministic for dynamic script loading.
I would like to see an example though if you can consistently reproduce it on ToT.

John J Barton

unread,
Oct 17, 2011, 11:32:22 PM10/17/11
to Vsevolod Vlasov, google-chrome-...@googlegroups.com
Vsevolod sent me some additional information on this issue. Key points:
  1) The cache behavior for scripts depends when the script is loaded relative to the document 'load' event. So anything like 'defer' or require.js is going to be erratic.
  2) The memory cache is keyed by URL. If a script is loaded twice at different times, then the current cache has no way to distinguish them.

I now think that Tim Meadowcroft is on the right track. As developers, we want to simulate the user experience so we can debug the site. "reload" means  for us "start over, do it again" (99% of the time). That is not what reload implements. We should be using "open in new window". 

I wonder if hitting "Enter" on the location bar implements Reload or Open-in-new-tab-but-actually-this-one?

jjb

Paul Irish

unread,
Oct 17, 2011, 11:38:24 PM10/17/11
to google-chrome-...@googlegroups.com
Worth pointing out just because...

Incognito mode not only gives you an empty cache but also has no extensions running by default, which is a pleasant blank slate to return to and make sure you have your sanity.
So at least as a workaround you can repeatedly close and open incognito to work from a freshly empty cache.

:)

_
Paul
Chrome Developer Advocate

Tim Meadowcroft

unread,
Oct 18, 2011, 5:04:50 AM10/18/11
to google-chrome-...@googlegroups.com


On Tuesday, October 18, 2011 4:38:24 AM UTC+1, Paul Irish wrote:
Worth pointing out just because...

Incognito mode not only gives you an empty cache but also has no extensions running by default, which is a pleasant blank slate to return to and make sure you have your sanity.
So at least as a workaround you can repeatedly close and open incognito to work from a freshly empty cache.


Good point, and the chrome extension I posted(*) simply takes the following nervous twitch (keystrokes shown as uppercase simply to make it easier to see 'l' is not '1' etc)

 Ctrl-Shift-I (close Developer Tools assuming it's open)
 Ctrl-L       (cursor to omnibox selecting current URL)
 Ctrl-C       (copy URL to clipboard)
 Ctrl-W       (close tab)
 Ctrl-T       (new tab, cursor automatically goes to the omnibox)
 Ctrl-V       (paste url)
 Enter        (navigate)

and simply automates it with the code in a chrome extension (gives you access to chrome.* APIs)

  var megaReloadTab = function(tab){

    var currUrl = tab.url, currIndex = tab.index, currId = tab.id;


    // if we make the new tab with the same URL (ie pass the url to the create call)

    // then we seem to get the same cache issues, but if we let the tab make itself

    // first and THEN go to the URL, it seems better....

    // We make a new empty tab before removing the old one so that, if this is the

    // only tab open, we don't close the browser itself :)

    chrome.tabs.create({ index: currIndex},

                       function(newtab) {

                           chrome.tabs.remove(currId, function() {

                               chrome.tabs.update(newtab.id, { url: currUrl });

                               console.log("Made new tab for "+currUrl);

                           });

                       });

  };


Adapting the twitch to make a new incognito window is simply replacing Ctrl-T with Shift-Ctrl-N, and I expect a variation in the code with the option to make a new incognito window wouldn't take much if anyone thinks it might be useful but of course if the extension isn't loaded by default in there then you couldn't call this repeatedly from each such instance - any chance perhaps of letting the creator of an incognito window specify that it should be loaded?? :)

--
T

See also JsError = https://chrome.google.com/webstore/detail/nnplccbllaclkbbmoldiamkhgohelbjh to see indications of JS errors without opening devtools 

mig...@design-union.com

unread,
Apr 11, 2012, 11:09:29 AM4/11/12
to google-chrome-...@googlegroups.com
ctrl+f5 works like a charm, thanks so much! (was driving me crazy) 

ryan...@gmail.com

unread,
Oct 17, 2013, 4:02:41 PM10/17/13
to google-chrome-...@googlegroups.com
Sometimes Ctrl+F5 doesn't work right away either. With recent version of Chrome:

1. Open dev tools (F12)
2. Right click on the "Reload this Page" icon in the main chrome window.
3. Select "Empty Cache and Hard Reload"

Tada!

rayf...@gmail.com

unread,
Mar 7, 2014, 10:31:52 AM3/7/14
to google-chrome-...@googlegroups.com, ryan...@gmail.com
So awesome. Thank you.
Message has been deleted

mgui...@gmail.com

unread,
Mar 17, 2014, 6:59:16 AM3/17/14
to google-chrome-...@googlegroups.com
Great !! thanks !

Jonathan Garbee

unread,
Mar 18, 2014, 11:15:26 AM3/18/14
to google-chrome-...@googlegroups.com
Also when you are developing, you can say "Disable Cache (while devtools are open)" in the main settings tab. That way the cache is always cleared when the dev tools are open, and you can still browse normally otherwise.


--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/8ead9225-7886-40ed-92bf-d24a5075ee74%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

sshe...@gmail.com

unread,
May 21, 2014, 10:53:22 AM5/21/14
to google-chrome-...@googlegroups.com
Clear the cache in Chrome is a big problem for us. I have an web application which use a compressed js file(compressed size about 1400kb). Recently I modified this file, because the first time when I deploy in the production, I didn't put version number of set no cache in the header, now I even change my url, I still found the web use the old js file, all other browsers like FireFox, IE updated. Although I have an announcement at the beginning of the web to ask users clear their cache at the first time use, but I cannot guarantee all the uses will clear their Chromes' cache. And we even recommend users  to use Chrome. Anyone has good suggestion to clear users' cache? Because I cannot control this.


jwilkin...@yahoo.com

unread,
May 23, 2014, 6:30:48 AM5/23/14
to google-chrome-...@googlegroups.com

PhistucK

unread,
May 23, 2014, 6:39:59 AM5/23/14
to Google Chrome Developer Tools
A universal hack is to just append some version number to the query string.
<script src="some-script.js?v=1"></script>
This makes sure all of your users are up to date with the latest version of that file (unless the HTML is also cached).

The only issue with this approach is that proxy servers do not handle it well and retrieve the URL every time.


PhistucK


On Wed, May 21, 2014 at 5:53 PM, <sshe...@gmail.com> wrote:
Clear the cache in Chrome is a big problem for us. I have an web application which use a compressed js file(compressed size about 1400kb). Recently I modified this file, because the first time when I deploy in the production, I didn't put version number of set no cache in the header, now I even change my url, I still found the web use the old js file, all other browsers like FireFox, IE updated. Although I have an announcement at the beginning of the web to ask users clear their cache at the first time use, but I cannot guarantee all the uses will clear their Chromes' cache. And we even recommend users  to use Chrome. Anyone has good suggestion to clear users' cache? Because I cannot control this.


--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.

sshe...@gmail.com

unread,
May 23, 2014, 10:06:05 AM5/23/14
to google-chrome-...@googlegroups.com
Thank you. My situation is I didn't put the version number at the first in deployment, so users already has <script src="some-script.js"></script>; I added now, but it didn't work for Chrome. I tried several ways, even I change the url, from www.something.com/map.aspx to www.something.com/map1.aspx; it only works for IE and FireFox, not Chrome.



On Friday, 23 May 2014 04:39:59 UTC-6, PhistucK wrote:
A universal hack is to just append some version number to the query string.
<script src="some-script.js?v=1"></script>
This makes sure all of your users are up to date with the latest version of that file (unless the HTML is also cached).

The only issue with this approach is that proxy servers do not handle it well and retrieve the URL every time.


PhistucK


On Wed, May 21, 2014 at 5:53 PM, <sshe...@gmail.com> wrote:
Clear the cache in Chrome is a big problem for us. I have an web application which use a compressed js file(compressed size about 1400kb). Recently I modified this file, because the first time when I deploy in the production, I didn't put version number of set no cache in the header, now I even change my url, I still found the web use the old js file, all other browsers like FireFox, IE updated. Although I have an announcement at the beginning of the web to ask users clear their cache at the first time use, but I cannot guarantee all the uses will clear their Chromes' cache. And we even recommend users  to use Chrome. Anyone has good suggestion to clear users' cache? Because I cannot control this.


--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

PhistucK

unread,
May 23, 2014, 10:31:49 AM5/23/14
to Google Chrome Developer Tools
That seems weird and highly unlikely. The browser must send different requests for different URLs and the server responds accordingly. Your situation suggests that something is not right in your client side or server side code. This requires investigation.
I guess you are using Windows. If so, launch Fiddler2 and see what is going on there. Does the browser send a request that looks different than the request sent by Internet Explorer? Does the server send a response that looks different than the response it sends to Internet Explorer?


PhistucK


To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/9ccf9248-4341-41f2-9026-5925921bbda6%40googlegroups.com.

Shengqi Song

unread,
May 23, 2014, 11:01:23 AM5/23/14
to google-chrome-...@googlegroups.com
Yes, I use windows. And the situation is a little bit complicated. aspx file has an iframe, the map shows in iframe. The url for iframe is a template, the template doesn't change, this is possible the reason that Chrome doesn't change. If  I use Chrome, check the Network->Initiator, I found the js file still doesn't update.


--
You received this message because you are subscribed to a topic in the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-chrome-developer-tools/JGVKZgMNSuc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/CABc02_J10rJHwtw%3DTscesCH_vqprLeaQsaBD%3DHCOYQK8U02BAg%40mail.gmail.com.

PhistucK

unread,
May 23, 2014, 11:15:36 AM5/23/14
to Google Chrome Developer Tools
The previous state that you mentioned (different URLs have identical responses) is the one that seems unlikely. Using the same URL would use the cache in most circumstances, unless the HTTP headers are configured appropriately.

Anyway, if you still have issues after investigating, you should start a new thread with the details instead of continuing this thread, as your issue is more specific.


PhistucK


Reply all
Reply to author
Forward
0 new messages