How to force Chrome's script debugger to reload javascript?

前端 未结 15 1918
天涯浪人
天涯浪人 2020-12-12 09:56

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 th

相关标签:
15条回答
  • 2020-12-12 10:07

    enter image description here

    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.

    0 讨论(0)
  • 2020-12-12 10:07

    You can always clear a specific file by doing the following:

    1. Open Dev Tools
    2. Click on the Sources tab
    3. Find your script / image / file
    4. Check the right panel to see if your file is up to date

    If not:

    1. Right click the resource in the left panel and choose 'Open Link in New Tab'
    2. Force a reload of the resource with the methods above. (See @Bishoy Hanna's example)

    This is very handy if you have resources that are in frames and CTRL+F5 is not force refreshing them.

    0 讨论(0)
  • 2020-12-12 10:07

    You can also use this Chrome extension to quickly switch between using or not the cache: https://chrome.google.com/webstore/detail/cache-killer/jpfbieopdmepaolggioebjmedmclkbap

    0 讨论(0)
  • 2020-12-12 10:08

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

    0 讨论(0)
  • 2020-12-12 10:10

    On Windows, Ctrl+Shift+r would force reload the script in chrome.

    0 讨论(0)
  • 2020-12-12 10:18

    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.

    0 讨论(0)
提交回复
热议问题