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.
我非常喜欢在chrome调试器中编辑javascript的功能,但是我发现让调试器从服务器重新获取javascript会有很大的问题。
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.
有时,我不得不关闭调试器并重新加载框架,但是其他时候(在这种情况下,我不能确定这是什么情况),我必须清除临时的internet缓存。有时我发誓我必须完全关闭chrome,然后清除缓存,然后在调试器最终显示最新的脚本之前加载页面。
(NB. There is no caching of the script by the web server)
(NB。web服务器不缓存脚本)
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?
我想知道是否有人知道一个快速简单的方法来告诉调试器使所有的javascript失效,并在重新加载页面时重新获取它?
15 个解决方案
#1
#2
119
That's the best way I'm living on...Take care the inspector window must be kept opened in order to see this context menu while holding on the refresh button BTW: I usually use Empty cache and hard reload
那是我生活的最好方式……请注意,检查器窗口必须保持打开状态,以便在按住refresh按钮时看到这个上下文菜单。顺便说一句:我通常使用空缓存和硬重载
It has another Advantage, It keeps all other websites stuff saved, just reloading and clearing this one only.
它还有另一个优势,它可以保存所有其他网站的东西,只需要重新加载和清除。
#3
33
You can always clear a specific file by doing the following:
您可以通过以下步骤清除特定的文件:
- Open Dev Tools
- 开放的开发工具
- Click on the Sources tab
- 单击Sources选项卡
- Find your script / image / file
- 找到你的脚本/图像/文件
- Check the right panel to see if your file is up to date
- 检查右边的面板,看看您的文件是否最新
If not:
如果不是:
- Right click the resource in the left panel and choose 'Open Link in New Tab'
- 右键单击左侧面板中的资源,选择“在New Tab中打开链接”
- Force a reload of the resource with
CTRL+F5
(mac:Command-Shift-R
) - 使用CTRL+F5强制重载资源(mac: Command-Shift-R)
This is very handy if you have resources that are in frames and CTRL+F5
is not force refreshing them.
如果您有帧中的资源,并且CTRL+F5不是强制刷新它们,那么这将非常方便。
#4
11
Shift+F5 quickly clears the cache.
Shift+F5快速清除缓存。
#5
7
For Google chrome it is not Ctrl+F5. It's Shift+F5 to clear the current cache! It works for me !
对于谷歌chrome,它不是Ctrl+F5。Shift+F5清除当前缓存!这对我很有效!
#6
7
Here's a shortcut to DevTools:
这里有一个开发工具的快捷方式:
- F12 to open Chrome DevTools
- F12打开Chrome开发工具
- F1 to open DevTools Settings
- F1打开DevTools设置
- Check Disable cache (while DevTools is open) as shown below:
- 检查禁用缓存(当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.
注意:根据Dimi的评论更新。他们倾向于移动它,如果你注意到它发生了变化,让我知道或者更新你的帖子。
#7
2
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.
如果在开发人员工具中对javascript进行本地更改,则需要确保在重新加载页面之前关闭这些更改。
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.
在Sources选项卡中,打开脚本后,在脚本中右键单击并单击上下文菜单中的“本地修改”选项。这将显示保存修改的脚本列表。如果在该窗口中看到,开发人员工具将始终保留本地副本,而不是从服务器刷新副本。单击“回复”按钮,然后再次刷新,您应该得到新的副本。
#8
2
On Windows, Ctrl+Shift+r would force reload the script in chrome.
在Windows上,Ctrl+Shift+r将强制在chrome中重新加载脚本。
#9
1
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.
似乎Chrome调试器会将源文件加载到内存中,并且不会在浏览器缓存更新的情况下释放它们,也就是说,除了不同步的浏览器缓存外,它还有自己的缓存。至少,在处理源映射文件时是这样(我正在调试打字稿源)。在成功地刷新浏览器缓存并验证之后,通过直接浏览源文件,您可以下载更新后的文件,但是一旦在调试器中重新打开文件,它将继续返回旧文件,无论来自普通浏览器缓存的版本是什么。非常烦人。
I would consider this a bug in chrome. I use version Version 46.0.2490.71 m.
我认为这是chrome的一个缺陷。我使用版本46.0.2490.71 m。
The only thing that helps, is restarting chrome (close down all chrome browsers).
唯一有帮助的是重新启动chrome(关闭所有chrome浏览器)。
#10
0
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.
如果您想要缓存,并且只需要重新加载文件,您可以转到dev工具的network选项卡,清除所加载的内容。下次它将不会从缓存中加载它。您将获得最新的更改。
#11
0
If you're running a local server on Apache, you can get what look like caching problems. This happened to me when I had a Apache server running under Vagrant (in virtualbox).
如果您在Apache上运行本地服务器,您可以得到类似于缓存的问题。当我有一个Apache服务器在Vagrant(在virtualbox中)下运行时,我就遇到了这种情况。
Just add the following lines to your config file (/etc/httpd/conf/httpd.conf
or equivalent):
只需向配置文件(/etc/httpd/conf/httpd)添加以下代码行。conf或同等):
#Disable image serving for network mounted drive
EnableSendfile off
Note that it's worth searching through the config file to see if EnableSendfile
is set to on
anywhere else.
注意,在配置文件中搜索是否在其他地方设置了EnableSendfile是值得的。
#12
0
There are also 2 (quick) workarounds:
还有两个快速解决方案:
- Use incognito mode wile debugging, close the window and reopen it.
- 使用incognito模式wile调试,关闭窗口并重新打开。
- Delete your browsing history
- 删除你的浏览历史
#13
0
Deactivating Breakpoints caused the new script to load for me.
使断点失效导致新脚本为我加载。
#14
0
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.
在我看来,在chrome的“私人浏览会话”中工作是最容易的,以确保您的javascript文件不会来自缓存。
#15
-1
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
您还可以使用这个Chrome扩展在使用或不使用缓存之间快速切换:https://chrome.google.com/webstore/detail/cache-killer/jpfbieopdmepaolggioebjmedmclkbap
#1
278
While you are developing your script, try disabling the Chrome cache.
在开发脚本时,请尝试禁用Chrome缓存。
When you reload the page, the JavaScript should now get refreshed.
重新加载页面时,JavaScript现在应该刷新。
Chrome circa 2011
Chrome circa 2018
#2
119
That's the best way I'm living on...Take care the inspector window must be kept opened in order to see this context menu while holding on the refresh button BTW: I usually use Empty cache and hard reload
那是我生活的最好方式……请注意,检查器窗口必须保持打开状态,以便在按住refresh按钮时看到这个上下文菜单。顺便说一句:我通常使用空缓存和硬重载
It has another Advantage, It keeps all other websites stuff saved, just reloading and clearing this one only.
它还有另一个优势,它可以保存所有其他网站的东西,只需要重新加载和清除。
#3
33
You can always clear a specific file by doing the following:
您可以通过以下步骤清除特定的文件:
- Open Dev Tools
- 开放的开发工具
- Click on the Sources tab
- 单击Sources选项卡
- Find your script / image / file
- 找到你的脚本/图像/文件
- Check the right panel to see if your file is up to date
- 检查右边的面板,看看您的文件是否最新
If not:
如果不是:
- Right click the resource in the left panel and choose 'Open Link in New Tab'
- 右键单击左侧面板中的资源,选择“在New Tab中打开链接”
- Force a reload of the resource with
CTRL+F5
(mac:Command-Shift-R
) - 使用CTRL+F5强制重载资源(mac: Command-Shift-R)
This is very handy if you have resources that are in frames and CTRL+F5
is not force refreshing them.
如果您有帧中的资源,并且CTRL+F5不是强制刷新它们,那么这将非常方便。
#4
11
Shift+F5 quickly clears the cache.
Shift+F5快速清除缓存。
#5
7
For Google chrome it is not Ctrl+F5. It's Shift+F5 to clear the current cache! It works for me !
对于谷歌chrome,它不是Ctrl+F5。Shift+F5清除当前缓存!这对我很有效!
#6
7
Here's a shortcut to DevTools:
这里有一个开发工具的快捷方式:
- F12 to open Chrome DevTools
- F12打开Chrome开发工具
- F1 to open DevTools Settings
- F1打开DevTools设置
- Check Disable cache (while DevTools is open) as shown below:
- 检查禁用缓存(当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.
注意:根据Dimi的评论更新。他们倾向于移动它,如果你注意到它发生了变化,让我知道或者更新你的帖子。
#7
2
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.
如果在开发人员工具中对javascript进行本地更改,则需要确保在重新加载页面之前关闭这些更改。
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.
在Sources选项卡中,打开脚本后,在脚本中右键单击并单击上下文菜单中的“本地修改”选项。这将显示保存修改的脚本列表。如果在该窗口中看到,开发人员工具将始终保留本地副本,而不是从服务器刷新副本。单击“回复”按钮,然后再次刷新,您应该得到新的副本。
#8
2
On Windows, Ctrl+Shift+r would force reload the script in chrome.
在Windows上,Ctrl+Shift+r将强制在chrome中重新加载脚本。
#9
1
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.
似乎Chrome调试器会将源文件加载到内存中,并且不会在浏览器缓存更新的情况下释放它们,也就是说,除了不同步的浏览器缓存外,它还有自己的缓存。至少,在处理源映射文件时是这样(我正在调试打字稿源)。在成功地刷新浏览器缓存并验证之后,通过直接浏览源文件,您可以下载更新后的文件,但是一旦在调试器中重新打开文件,它将继续返回旧文件,无论来自普通浏览器缓存的版本是什么。非常烦人。
I would consider this a bug in chrome. I use version Version 46.0.2490.71 m.
我认为这是chrome的一个缺陷。我使用版本46.0.2490.71 m。
The only thing that helps, is restarting chrome (close down all chrome browsers).
唯一有帮助的是重新启动chrome(关闭所有chrome浏览器)。
#10
0
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.
如果您想要缓存,并且只需要重新加载文件,您可以转到dev工具的network选项卡,清除所加载的内容。下次它将不会从缓存中加载它。您将获得最新的更改。
#11
0
If you're running a local server on Apache, you can get what look like caching problems. This happened to me when I had a Apache server running under Vagrant (in virtualbox).
如果您在Apache上运行本地服务器,您可以得到类似于缓存的问题。当我有一个Apache服务器在Vagrant(在virtualbox中)下运行时,我就遇到了这种情况。
Just add the following lines to your config file (/etc/httpd/conf/httpd.conf
or equivalent):
只需向配置文件(/etc/httpd/conf/httpd)添加以下代码行。conf或同等):
#Disable image serving for network mounted drive
EnableSendfile off
Note that it's worth searching through the config file to see if EnableSendfile
is set to on
anywhere else.
注意,在配置文件中搜索是否在其他地方设置了EnableSendfile是值得的。
#12
0
There are also 2 (quick) workarounds:
还有两个快速解决方案:
- Use incognito mode wile debugging, close the window and reopen it.
- 使用incognito模式wile调试,关闭窗口并重新打开。
- Delete your browsing history
- 删除你的浏览历史
#13
0
Deactivating Breakpoints caused the new script to load for me.
使断点失效导致新脚本为我加载。
#14
0
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.
在我看来,在chrome的“私人浏览会话”中工作是最容易的,以确保您的javascript文件不会来自缓存。
#15
-1
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
您还可以使用这个Chrome扩展在使用或不使用缓存之间快速切换:https://chrome.google.com/webstore/detail/cache-killer/jpfbieopdmepaolggioebjmedmclkbap