脚本强制IE8缓存行为 [英] Script to force IE8 cache behaviour

查看:168
本文介绍了脚本强制IE8缓存行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IE8中,缓存开发人员工具上有一个名为始终从服务器刷新的选项。有可能有一些javascript或类似的强迫这种行为或我必须总是手动吗?



我试过

 < META HTTP-EQUIV =PragmaCONTENT =no-cache> 

但我的应用程序中的刷新问题似乎只能通过检查始终从服务器刷新来解决缓存选项面板。



谢谢

解决方案

如果您正在使用jQuery,你可以这样做:


$ .ajaxSetup({
cache:false
});


在使用jquery + ajax时解决了许多IE8缓存问题。



否则,您可以通过在.js uri的末尾附加唯一编号来使用缓存破坏程序。像这样:


http://mysite.com/myscript.js?=_11232131231323


当然,唯一的#可能是每个页面请求都是唯一的DateTime()。


in IE8, there's an option on cache developer tools called "refresh always from server". Is it possible to have some javascript or similar to force this behaviour or I have to do it always manually?

I've tried

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

but the refreshing issue in my application seems to be resolved only by checking "refresh always from server" on cache options panel.

Thanks

解决方案

If you're using jQuery, you can do:

$.ajaxSetup({ cache: false });

which has solved many IE8 caching issues for me when using jquery + ajax.

Otherwise, you could use a "cache-breaker" by appending a unique number to the end of the .js uri. Like so:

http://mysite.com/myscript.js?=_11232131231323

Of course, the unique # could be a DateTime() that is unique on every page request.

这篇关于脚本强制IE8缓存行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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