如何清除gwt中的缓存? [英] how to clear cache in gwt?

查看:392
本文介绍了如何清除gwt中的缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何清除 gwt 中的缓存?



或者有什么方法阻止浏览器将缓存保存在 gwt

解决方案

在部署GWT应用程序时,避免代理和浏览器缓存.nocache由GWT生成的.js文件。一个解决方案是实现一个servlet过滤器,该过滤器添加了控制缓存行为的必要HTTP头。



这是一个这样的过滤器: http://seewah.blogspot.com/2009/02/gwt-tips- 2-nocachejs-getting-cached-in.html



该示例中的标题为:

 日期:2010年11月24日星期三20:32:43 GMT 
过期时间:2000年11月1日星期三00:00:00 GMT
Pragma:no-cache
Cache-Control:no-cache,no-store,must-revalidate

Date 应设置为请求时间。



过期是最好设置在过去的某个时间,这迫使每个人都认为已经陈旧的内容。

Pragma 是一个已被 Cache-Control 取代的标签,但它并不会伤害它。



Cache-Control no-cache 表示浏览器或代理在将缓存副本发布到客户端之前必须重新验证缓存副本。 no-store 表示没有人保留一个缓存副本(这使得 no-cache 冗余)。 must-revalidate 表示浏览器/代理服务器必须遵守新鲜度信息并重新验证,同样也是 no-store p>

How can I clear the cache in gwt?

or is there any way that prevent browser to keep the cache in gwt?

解决方案

When you deploy a GWT-application it's important to avoid proxies and browsers to cache the .nocache.js-files generated by GWT. One solution is to implement a servlet filter that adds the necessary HTTP-headers that control the caching behaviour.

Here's such a filter: http://seewah.blogspot.com/2009/02/gwt-tips-2-nocachejs-getting-cached-in.html

The headers in that example are:

Date: Wed, 24 Nov 2010 20:32:43 GMT
Expires: Wed, 01 Nov 2000 00:00:00 GMT
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate

Date should be set to the time of the request.

Expires is best set to sometime in the past, this forces everyone to consider the content already stale.

Pragma is a tag that has been superseded by Cache-Control, but it doesn't hurt to have it.

Cache-Control no-cache means a browser or proxy must revalidate a cached copy before releasing it to the client. no-store means no one is ever keeping a cached copy (which makes no-cache redundant). must-revalidate says the browser/proxy must obey freshness information and revalidate, also redundant with no-store.

这篇关于如何清除gwt中的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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