Reputation: 7715
I really like the ability to edit javascript in the chrome debugger however, I find that it can be really problematic getting the debugger to re-fetch the JavaScript from the server.
Sometimes I have to go as far just closing the debugger and reloading the frame works OK - but other times (an dI cannot pin down under what conditions this occurs) I have to clear my temporary internet cache. Sometimes I swear I have to close chrome completely, then clear the cache and then load the page before the debugger finally shows me the most up-to-date script.
(NB. There is no caching of the script by the web server)
I was wondering if anyone knew of a quick and easy way to tell the debugger to invalidate all its javascript and fetch it all anew on page reload?
Upvotes: 271
Views: 205217
Reputation: 5692
You can also use this Chrome extension to quickly switch between using or not the cache: https://chromewebstore.google.com/detail/classic-cache-killer/kkmknnnjliniefekpicbaaobdnjjikfp
Upvotes: 0
Reputation: 31
If there is document on URL: file:///C:/Users/user/Desktop/site/index.html
Add any parameter to your URL, like this: file:///C:/Users/user/Desktop/site/index.html?foo=777
and the browser'll refresh all sites resources
Upvotes: 0
Reputation: 1234
Right click on reload button in chrome and click "Empty Cache and Hard Reload"
Upvotes: 1
Reputation: 19396
Here's a shortcut to DevTools:
Note: Updated per Dimi's comment. They tend to move it so let me know or update the post if you notice that it's changed.
Upvotes: 11
Reputation: 10159
You can always clear a specific file by doing the following:
If not:
This is very handy if you have resources that are in frames and CTRL+F5
is not force refreshing them.
Upvotes: 40
Reputation: 4589
The context menu shown above is accessible by right clicking / presssing & holding the "reload" button, while Chrome Dev Tools is opened.
Empty cache and hard reload works best for me.
Another Advantage: This option keeps all other opened tabs and website data untouched. It only reloads and clears the current page.
Upvotes: 146
Reputation: 82944
While you are developing your script, try disabling the Chrome cache.
When you reload the page, the JavaScript should now get refreshed.
You can also access it on the network tab:
Upvotes: 356
Reputation: 300
In my opinion it's easiest to work in a 'private browsing session' of chrome, to ensure that your javascript files don't come from the cache.
Upvotes: 0
Reputation: 2634
On Windows, Ctrl+Shift+r would force reload the script in chrome.
Upvotes: 3
Reputation: 4293
There are also 2 (quick) workarounds:
Upvotes: 0
Reputation: 5646
It seems as the Chrome debugger loads source files into memory and wont let them go despite of browser cache updates, i.e. it has its own cache apart from the browser cache that is not in sync. At least, this is the case when working with source mapped files (I am debugging typescript sources). After successfully refreshing browser cache and validating that by browsing directly to the source file, you download the updated file, but as soon as you reopen the file in the debugger it will keep returning the old file no matter the version from the ordinary browser cache. Very anoying indeed.
I would consider this a bug in chrome. I use version Version 46.0.2490.71 m.
The only thing that helps, is restarting chrome (close down all chrome browsers).
Upvotes: 2
Reputation: 1874
For Google chrome it is not Ctrl+F5. It's Shift+F5 to clear the current cache! It works for me !
Upvotes: 9
Reputation: 1
If the files which you are loading are cached and if the changes you have made does not reflect in the code then there are 2 ways you can deal with this
Clear the Cache as everyone told
If u want Cache and only the files have to be reloaded , you can go to network tab of the dev tool and clear whatever was loaded. next time it will not load it from cache. you will have your latest changes.
Upvotes: 0
Reputation: 4921
If you are making local changes to a javascript in the Developer Tools, you need to make sure that you turn OFF those changes before reloading the page.
In the Sources tab, with your script open, right-click in your script and click the "Local Modifications" option from the context menu. That brings up the list of scripts you've saved modifications to. If you see it in that window, Developer Tools will always keep your local copy rather than refreshing it from the server. Click the "revert" button, then refresh again, and you should get the fresh copy.
Upvotes: 2