You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Henri Dupre <he...@gmail.com> on 2006/07/30 22:38:20 UTC

disable caching on browsers and proxies by default?

When we deployed our tapestry 4 app, we did hit a huge issue that was not
visible on our tests about the caching.
http://issues.apache.org/jira/browse/TAPESTRY-969
It seems browsers obey quite well to the meta tag but not proxies.
If the webapp doesn't send cache-control directives, then proxies *do* cache
the content. It was difficult to diagnose at the beginning why the shopping
cart did not change when customers added a new product. It happens that many
people are behind proxies which were caching all the content.
IIS and .NET (and many other webapps) seem to output by default http headers
to disable caching.
Currently with tapestry we have the following webrequestservicerfilter
*

public* *class* FixHeadersRequestFilter *implements* *
WebRequestServicerFilter* {*
**public* *void* service(WebRequest request, WebResponse response,
WebRequestServicer servicer) *throws* IOException {
String svcValue = request.getParameterValue(ServiceConstants.*SERVICE*);*
**boolean* doCache = (request.getSession(*false*) == *null*);
doCache = *doCache* ||Tapestry.*ASSET_SERVICE*.equals(svcValue);*
**if* (!doCache) {*
*response.setHeader("Cache-Control", "private,no-cache,no-*store*");
} *else* {
response.setHeader("Cache-Control", "max-age=3600");
}*
*servicer.service(request, response);
*}
}*
I believe though that this would be a good setting to have by default so
that other people going live are not hitting this issue. Ideally, it would
be nice if this could be plugged to the setting "disableCaching" of the
@Shell component but I'm not sure how this could be implemented.
Thoughs?

-- 
Henri Dupre
Actualis Center