Javascript 如何在 InternetExplorer 8 中禁用缓存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2755800/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 01:47:49  来源:igfitidea点击:

How to disable cache in InternetExplorer 8

javascriptinternet-explorercaching

提问by Don Ch

How can I disable cache in IE8 ? We are doing Javascript development and testing it in IE8, but we have to clear the cache every time we make changes to the Javascript files.

如何在 IE8 中禁用缓存?我们正在IE8中进行Javascript开发和测试,但是每次对Javascript文件进行更改时都必须清除缓存。

回答by EMP

Go to Internet Options. On the Generaltab, under Browsing Historyclick Settings. Select the "Every time I visit the webpage" radio button.

转到Internet 选项。在“常规”选项卡上的“浏览历史记录下,单击“设置”。选择“每次访问网页时”单选按钮。

This doesn't "disable" the cache per se, but it should fix your underlying problem - the JS files should be reloaded every time.

这不会“禁用”缓存本身,但它应该可以解决您的潜在问题 - 每次都应该重新加载 JS 文件。

回答by Nick Craver

Ctrl+F5Should cause a full page refresh including all that cached javascript.

Ctrl+F5应该会导致整页刷新,包括所有缓存的 javascript。

Occasionally though, you'll still need a cache clear, because even Ctrl+F5 won't work, for reasons beyond comprehension IE can't even get "refresh" right 100% of the time.

有时,您仍然需要清除缓存,因为即使 Ctrl+F5 也不起作用,出于无法理解的原因,IE 甚至无法 100% 地“刷新”正确。

回答by user97410

If that fails, a random parameter on the query string will do it:

如果失败,查询字符串上的随机参数将执行此操作:

index.html?a=346456

index.html?a=346456

回答by TheHippo

Load you JavaScript this way.

以这种方式加载 JavaScript。

<html>
...
<script type="text/javascript">
document.write('<script src="yourscript.js?'+Math.random()+'"></script>');
</script>
...
</html>

Edit:In case this is not obvious, remove this code as soon you will go into production!

编辑:如果这不明显,请在投入生产后立即删除此代码!

回答by gmhk

In order to set the browser cache turned off. Follow the instructions below:

为了设置浏览器缓存关闭。请按照以下说明操作:

MS IE

微软IE浏览器

  1. from a menu select "Tools" for IE5 or "View" for IE4
  2. select "Internet Options"
  3. in "Temporary Internet Files" section click on "Settings"
  4. select "Every visit to the page" for "Check for newer versions of stored pages" save the settings I hope this may help please check
  1. 从菜单中选择 IE5 的“工具”或 IE4 的“查看”
  2. 选择“互联网选项”
  3. 在“Internet 临时文件”部分点击“设置”
  4. 为“检查存储页面的更新版本”选择“每次访问页面”保存设置我希望这可能会有所帮助请检查

回答by Mac

hit "Fn F12" to open developer tools

点击“Fn F12”打开开发者工具

click Cache

单击缓存

choose "Always refresh from server"

选择“始终从服务器刷新”

Every time you refresh it should be clearing the cache, but there are also quick access cache clearing from the cache menu or the shortcuts that are active when the dev tools are open.

每次刷新时都应该清除缓存,但也可以从缓存菜单或开发工具打开时激活的快捷方式中快速访问缓存清除。

*Note- you must leave the dev tools window open, it doesn't have to be up front, but it has to remain open for the cache to remain disabled.

*注意 - 您必须让开发工具窗口保持打开状态,它不必预先设置,但必须保持打开状态才能使缓存保持禁用状态。

回答by josh3736

Ctrl+Shift+Delwill open the Clear Private Data dialog (or select it from the Safety menu). Uncheck everything but the first two items to clear only the cache.

Ctrl+ Shift+Del将打开清除私人数据对话框(或从安全菜单中选择它)。取消选中除前两项之外的所有内容以仅清除缓存。

You shouldn't have to clear the cache though. If you access your js files through a web server (such as IIS running locally), the normal cache control mechanisms shoulddo the trick. If they don't, a Ctrl+F5usually fixes the problem.

不过,您不必清除缓存。如果您通过 Web 服务器(例如本地运行的 IIS)访问您的 js 文件,则正常的缓存控制机制应该可以解决问题。如果他们不这样做,Ctrl+F5通常可以解决问题。

回答by John Ingle

If your javascript files are served exclusivley from a sub-directory, you could enable immediate content expiration for that directory in IIS. I recently had this problem serving content from a sub-directory and this was the fastest, simplest solution that I found.

如果您的 javascript 文件是从子目录中独占提供的,您可以在 IIS 中为该目录启用即时内容过期。我最近在从子目录提供内容时遇到了这个问题,这是我找到的最快、最简单的解决方案。

回答by Dan Revell

Open the IE debugging tools (F12), Cache on the menu, and select always refresh from server. This does mean you need to keep the debugging tools open.

打开IE调试工具(F12),菜单上的缓存,选择总是从服务器刷新。这确实意味着您需要保持调试工具打开。

回答by Eugen

Maybe a easier way not to have user refresh the browser is just to rename the js files (and css). This is what worked for me... as the server didn't like a random number after the .js file

也许不让用户刷新浏览器的更简单方法就是重命名 js 文件(和 css)。这对我有用......因为服务器不喜欢 .js 文件之后的随机数