how to clear 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
.