IE9直接使用缓存文件 [英] IE9 use cache files directly

查看:61
本文介绍了IE9直接使用缓存文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

我发现IE9和IE8在使用缓存方面存在差异。



testCache.html:

< html> 
< head>
< script type =" text / javascript"语言= QUOT; JavaScript的" SRC =" testCache.js"?>< /脚本>
< / head>
< body>
这是一个测试页面!
< / body>
< / html>




访问页面时,IE9直接在缓存中使用testCache.js,而不是确定文件是否有已更新。



如果直接刷新页面,IE9将检查文件是否有更新。

当文件尚未更新时, IE9将使用缓存文件;否则使用服务器上的最新testCache.js文件。



这种情况​​也发生在IE11中。



为什么会发生这种情况? 

如何在任何情况下让IE检查文件是否更新?



谢谢!

解决方案

我明白你的意思。


让IE总是有条件地取你的js ,你可以这样做。 为js创建一个文件夹,然后在IIS管理器中找到该文件夹​​及其HTTP Response Headers图标,双击,然后找到右侧的链接,设置公共标题... 将其更改为
立即过期。


这将导致您的js文件被提供"Cache-Control:no-cache";标题。


这是用词不当,"no-cache"。 这实际上意味着在每次访问时重新验证。  IE将缓存js,但会使用这些条件标头进行后续请求:  If-None-Match(etags)和If-Modified-Since。


 


http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1


http://www.w3.org /Protocols/rfc2616/rfc2616-sec14.html#sec14.25


http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26



Hello!
I found a difference between IE9 and IE8 in using cache.

testCache.html:

<html>
<head>
<script type="text/javascript" language="javascript" src="testCache.js?"></script>
</head>
<body>
	This is a test page!
</body>
</html>


When visiting the page, IE9 directly using the testCache.js in cache, instead of determining whether the file has been updated.

If you refresh the page directly, IE9 will check the file for updates.
When the file has not been updated, IE9 will use the cache file; otherwise use the latest testCache.js file on the server.

This situation also occurs in IE11.

Why does this happen? 
And how to make IE in any case to check whether the file is updated?

Thank you!

解决方案

I see what you mean.

To make IE always conditionally fetch your js, you can do this.  Make a folder for the js, and then in IIS Manager, find this folder and its HTTP Response Headers icon, double-click, then find link on right, Set Common Headers...  Change that to Expires Immediately.

This will result in your js file being served with "Cache-Control: no-cache" header.

It is a misnomer, "no-cache".  This actually means to revalidate on every access.  IE will cache the js, but will make later requests with these conditional headers:  If-None-Match (etags) and If-Modified-Since.

 

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26


这篇关于IE9直接使用缓存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆