ericwang14 / webutilities

Automatically exported from code.google.com/p/webutilities
0 stars 0 forks source link

ResponseCacheFilter sets wrong value for X-ResponseCacheFilter for cache hits #52

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
With v0.0.7 ResponseCacheFilter#doFilter around line 236 looks as follows

if (cacheFound) {
  LOGGER.debug("Returning Cached response.");
  cacheObject.getWebUtilitiesResponseWrapper().fill(httpServletResponse);
  httpServletResponse.setHeader(CACHE_HEADER, CacheState.FOUND.toString());
  //fillResponseFromCache(httpServletResponse, cacheObject.getModuleResponse());
} else {

So, I guess the first thing to improve is to remove the commented line.

But more importantly the header must be set before the fill() method is called. 
Otherwise the response is committed and won't accept any changes. The effect is 
that the client sees X-ResponseCacheFilter:SKIPPED (the default) instead of 
X-ResponseCacheFilter:FOUND.

Original issue reported on code.google.com by marcel@frightanic.com on 11 Jul 2014 at 9:29

GoogleCodeExporter commented 9 years ago

Original comment by rr.patil...@gmail.com on 14 Jul 2014 at 2:30

GoogleCodeExporter commented 9 years ago

Original comment by rr.patil...@gmail.com on 14 Jul 2014 at 2:34

GoogleCodeExporter commented 9 years ago

Original comment by rr.patil...@gmail.com on 14 Jul 2014 at 2:34