本站首页    管理页面    写新日志    退出


«October 2025»
1234
567891011
12131415161718
19202122232425
262728293031


公告
 本博客在此声明所有文章均为转摘,只做资料收集使用。

我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:
日志总数:1304
评论数量:2242
留言数量:5
访问次数:7629869
建立时间:2006年5月29日




[TurboGears]How To Make IE Cache Less
软件技术

lhwork 发表于 2007/2/16 12:06:17

Internet Explorer is known to cache the responses of GET calls. The problem occurs if your javascript functions request the same url over and over again. Internet Explorer will cache the response of the first call, and subsequent calls will automatically return the same response, without actually contacting the server. There are two approaches to solve this problem. One approach could be to add a random part to the url (i.e.: /poll?random=f2dee87716f). So, the browser will think of it as a different URL everytime. An alternative approach could be to set the response headers correctly. The HTTP headers that need to be set are as follows: Expires: Sun, 19 Nov 1978 05:00:00 GMTCache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0Pragma: no-cache Here’s how I do it in TurboGears. To each method that I don’t want IE to cache, I add the strongly_expire decorator, like this: @expose() @strongly_expire def cant_cache_me(self, position): ... The code of the decorator, which is responsible to set the headers propertly: def strongly_expire(func): """Decorator that sends headers that instruct browsers and proxies not to cache. """ def newfunc(*args, **kwargs): cherrypy.response.headers['Expires'] = 'Sun, 19 Nov 1978 05:00:00 GMT' cherrypy.response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' cherrypy.response.headers['Pragma'] = 'no-cache' return func(*args, **kwargs) return newfunc


阅读全文(2936) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.821 second(s), page refreshed 144789724 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号