During development I have to "clear cache" in Firefox all the time in order to make it use the latest version of Javascript files.
在开发过程中,我必须一直在Firefox中“清除缓存”,以便让它使用最新版本的Javascript文件。
Is there some kind of setting (about:config) to turn off caching completely for Javascript files? Or, if not, for all files?
是否有某种设置(about:config)来完全关闭Javascript文件的缓存?或者,如果不是,对所有文件?
220
Enter "about:config" into the Firefox address bar and set:
在Firefox地址栏输入“about:config”并设置:
browser.cache.disk.enable = false
browser.cache.memory.enable = false
If developing locally, or using HTML5's new manifest attribute you may have to also set the following in about:config -
如果在本地开发,或者使用HTML5的新manifest属性,您可能还需要在about中设置以下内容:config -
browser.cache.offline.enable = false
61
The Web Developer Toolbar has an option to disable caching which makes it very easy to turn it on and off when you need it.
Web Developer Toolbar有一个禁用缓存的选项,当您需要时,可以很容易地打开和关闭它。
12
Have you tried to use CTRL-F5 to update the page?
你试过使用CTRL-F5来更新页面吗?
10
There is no specific option to disable caching only for Javascript, you will have to disable caching entirely.
只有Javascript才能禁用缓存,没有特定的选项,您必须完全禁用缓存。
FireBug has an option to disable the browser cache on the Network tab's drop down menu.
FireBug有一个选项可以在Network选项卡的下拉菜单上禁用浏览器缓存。
8
On the same page you want to disable the caching do this : FYI: the version am working on is 30.0
在相同的页面上,您希望禁用缓存:FYI:该版本正在处理的是30.0。
You can :
您可以:
After that it will reload page from its own (you are on) and every thing is recached and any furthure request are recahed every time too and you may keep the web developer open always to keep an eye and make sure its always on (check).
在那之后,它将重新加载自己的页面(您是on的),每件事都被重新处理,任何furthure请求也会被重新处理,您可以保持web开发人员始终保持开放,以保持关注并确保它始终处于打开状态(检查)。
7
If you're working with server side code you could generate a random number and append it to the end of the src in the following manner....
如果您正在使用服务器端代码可以生成一个随机数并将它附加到src的结束以下列方式....
src="yourJavascriptFile.js?randomNumber=434534"
src = " yourJavascriptFile.js ? randomNumber = 434534 "
with the randomNumber being randomly generated each time.
每次随机生成随机数。
6
Firefox 48 Developer Tools
Firefox 48开发工具
Allows you to turn off cache only when toolbox is open, which is perfect for web development:
允许您仅在工具箱打开时关闭缓存,这对于web开发是完美的:
https://stackoverflow.com/a/27397425/895245 has similar content, but positioning changed a bit since.
https://stackoverflow.com/a/27397425/895245也有类似的内容,但是定位从那以后就有点变化了。
4
I know I'm resurrecting an ancient question, but I was trying to solve this problem today and have an alternate solution. Toggling caching when I want to test was not really acceptable for me, and as others mentioned, hard refreshing (ctrl+shift+r) doesn't always work.
我知道我在重新提出一个古老的问题,但我今天试图解决这个问题,并有另一个解决方案。当我想要测试时切换缓存并不是真的可以接受的,正如其他人提到的,硬刷新(ctrl+shift+r)并不总是有效。
Instead, I opted to put the following in my vhost.conf file (can also be done in .htaccess) on my dev environment:
相反,我选择在vhost中添加以下内容。在我的开发环境上的conf文件(也可以在.htaccess中执行):
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
On my dev environment, this ensures that js and css are always retrieved. Additionally it doesn't affect the rest of my browsing, and it also works for all browsers, so testing in chrome / ie etc is also easy.
在我的开发环境中,这确保始终检索js和css。此外,它不影响我的其他浏览,它也适用于所有浏览器,所以在chrome / ie等环境下测试也很容易。
Found the snippet here, some other handy apache tricks as well: http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html#prevent-caching-with-htaccess
在这里找到了这个代码片段,还有一些其他便利的apache技巧:http://www.askapache.com/htaccess/using-http-header - htac.html #prevent- cache -htaccess
To make sure that my clients always see the latest version on production, we increment the query string on the js include on each update, ie
为了确保我的客户总是在产品上看到最新的版本,我们在每次更新时增加js包含的查询字符串
jquery.somefile.js?v=0.5
This forces my clients' browsers to update their local cache when they see a new querystring, but then caches the new copy until the file is updated again
这迫使我的客户端浏览器在看到新的querystring时更新本地缓存,然后缓存新的副本,直到再次更新文件
3
Best strategy is to design your site to build a unique URL to your JS files, that gets reset every time there is a change. That way it caches when there has been no change, but imediately reloads when any change occurs.
最好的策略是设计您的站点来为您的JS文件构建一个惟一的URL,每次发生更改时都要重置该URL。这样,当没有更改时,它会缓存,但当发生任何更改时,它会立即重新加载。
You'd need to adjust for your specific environment tools, but if you are using PHP/Apache, here's a great solution for both you, and the end-users.
您需要针对特定的环境工具进行调整,但是如果您正在使用PHP/Apache,那么对于您和最终用户来说,这里有一个很好的解决方案。
http://verens.com/archives/2008/04/09/Javascript-cache-problem-solved/
http://verens.com/archives/2008/04/09/Javascript-cache-problem-solved/
3
You can use CTRL-F5 to reload bypassing the cache.
可以使用CTRL-F5重载绕过缓存。
You can set the preferences in firefox not to use the cache
您可以在firefox中设置不使用缓存的首选项
network.http.use-cache = false
You can setup you web server to send a no-cache/Expires/Cache-Control headers for the js files.
您可以设置web服务器为js文件发送无缓存/过期/缓存控制头。
Here is an example for apache web server.
下面是apache web服务器的一个示例。
3
If you use FireBug, on the Network tab's drop down menu there is an option do disable the browser's cache.
如果使用FireBug,在Network选项卡的下拉菜单上有一个选项可以禁用浏览器的缓存。
1
There are pros and cons to the last two solutions posted, but they're both IMHO great solutions.
最后两种解决方案都有优点和缺点,但它们都是很棒的解决方案。
You may or may not want your session ID embedded in your url like that for tighter security. But in development that shouldn't matter, but what if you forget to remove it? Also does that really work? Wouldn't you need something like a sequential number generator (hit count stored in the session, or maybe even just if 1 then 0, if 0 then 1)?
为了更严格的安全性,您可能希望会话ID像这样嵌入到url中,也可能不希望这样。但在开发过程中,这并不重要,但如果您忘记删除它呢?这真的有用吗?难道你不需要一个序列数字生成器(在会话中存储的命中计数,或者即使是1然后0,如果0然后1)吗?
Adding a session id (or whatever sequencer) means you need to remember to add it to every resource you don't want cached. On the one hand that's better because you can just include your session id with just that resource you're actively developing and testing. On the other hand, it means you have to do that and you have to remember to remove that for production.
添加会话id(或任何序列)意味着您需要记住将它添加到不希望缓存的每个资源。一方面,这更好,因为您可以只使用正在积极开发和测试的资源来包含会话id。另一方面,这意味着你必须这么做,而且你必须记住为了生产而删除它。
Modifying the vhost.conf or the .htaccess file does the trick nicely without the need to remember to add and remove the session id. But the downside is performance of all js and css resources will be affected, and if you have large files, that's going to slow you down.
vhost修改。conf或.htaccess文件很好地解决了这个问题,无需记住添加和删除会话id。
Both seem like great, elegant solutions -- depends on your needs.
这两种方法看起来都很棒,都很优雅——这取决于你的需要。
1
I use CTRL-SHIFT-DELETE which activates the privacy feature, allowing you to clear your cache, reset COOKIEs, etc, all at once. You can even configure it so that it just DOES it, instead of popping up a dialog box asking you to confirm.
我使用CTRL-SHIFT-DELETE来激活隐私特性,允许你一次清除缓存、重置COOKIE等等。你甚至可以对它进行配置,这样它就可以做到这一点,而不是弹出一个对话框要求你确认。
1
In higher versions of Firefox, like Nightly, there is an options named "disable cache", you can find it by clicking the gear. And that options works only in current session, which means when you close inspector and restart it, you have to check it again if you want catch disabled.
在更高版本的Firefox中,比如Nightly,有一个名为“禁用缓存”的选项,你可以通过点击gear找到它。该选项仅在当前会话中有效,这意味着当您关闭检查器并重新启动它时,如果您希望禁用catch,您必须再次检查它。
0
After 2 hours of browsing for various alternatives, this is something that worked for me.
在浏览了两个小时的各种选择之后,这对我来说很有用。
My requirement was disabling caching of js and css files in my spring secured web application. But at the same time caching these files "within" a particular session.
我的要求是在我的spring安全web应用程序中禁用js和css文件的缓存。但与此同时,将这些文件“缓存到”一个特定的会话中。
Passing a unique id with every request is one of the advised approaches.
在每个请求中传递唯一的id是建议的方法之一。
And this is what I did :- Instead of
这就是我所做的:-而不是
I used
我使用
Any cons to the above approach are welcome. Security Issues ?
欢迎对上述方法提出反对意见。安全问题?
0
In firefox 45, disk cache options can be set by changing the value of: browser.cache.disk.enable
在firefox 45中,可以通过更改:browres .cache.disk.enable来设置磁盘缓存选项
The value can be set on the "about:config" page.
可以在“about:config”页面上设置该值。
On http://kb.mozillazine.org/About:config_entries#Browser I found the following description for "browser.cache.disk.enable":
在http://kb.mozillazine.org/About:config_entries#浏览器中,我找到了“browser.cache.disk.enable”的描述:
True (default): Use disk cache, up to capacity specified in browser.cache.disk.capacity False: Disable disk cache (same effect as setting browser.cache.disk.capacity to 0)
True(默认):使用磁盘缓存,直到浏览器.cache.disk中指定的容量为止。容量错误:禁用磁盘缓存(与设置browsr .cache.disk相同的效果)。容量为0)
0
First of All, this can be easily done, for e.g. by PHP to force the browser to renew files based on cache date (expiration time). If you just need it for experimental needs, then try to use ctrl+shift+del to clear all cache at once inside Firefox browser. The third solution is to use many add-ons that exits for Firefox to clear cache based on time lines.
首先,这很容易做到,例如,PHP可以强制浏览器根据缓存日期(过期时间)更新文件。如果您只是为了实验需要而需要它,那么尝试使用ctrl+shift+del来一次清除Firefox浏览器中的所有缓存。第三种解决方案是使用许多为Firefox提供的插件来基于时间线清除缓存。