History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CACHE-116
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Lars Torunski
Reporter: patrick sard
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
OSCache

CacheFilter sends back a 304 (not modified) response when client cache is de-activated

Created: 19/Oct/04 05:29 AM   Updated: 27/Apr/05 02:33 PM
Component/s: Filters
Affects Version/s: 2.1
Fix Version/s: 2.1.1

Environment: Bea Weblogic 7.0 sp3, Solaris
Issue Links:
Duplicate
 
This issue is duplicated by:
CACHE-168 oscache filter test example applicati... Major Closed
Related
This issue relates to:
CACHE-58 Check If-Modified-Since header in ca... Major Closed
 


 Description  « Hide
after upgrading to 2.1RC1 to fix a bug I had with 2.0 I found out a cache issue due to the CacheFilter class (my cache config hasn't changed between the OSCache release upgrade).

All my JSP headers have a header which basically says "don't want cache of any sort at browser or proxy or web server level for dynamic pages!" but despite of that calling the same page again and again after the first call keeps sending back a 304 (NOT MOFIFIED), response sent by ... OSCache CacheFilter (line 77 of source code)!

There's probably more than a single way to solve the problem, anyway I'm enclosing a simple patch which forces to always send back the cache content of OSCache when client last modified date is not set (clientLastModified == -1) which should always be the case if and only if the client cache was de-activated.

Indeed CacheFilter upon request checks the last-modified header date and compares it with its own internal date for the cached content.
In my case it happens the be the same: -1 (no client cache of any sort at browser or proxy or web server level and the cached content has been created with a lastModified date of -1 (which the default value in the ResponseContent class)).
So the test of line 76 is true (-1 >= -1) and an erroneous NOT-MODIFIED Response is sent back to the client !
----------------
PATCH
===========
--- CacheFilter.java.orig 2004-09-18 16:52:28.000000000 +0200
+++ CacheFilter.java 2004-10-19 11:32:59.104057600 +0200
@@ -73,7 +73,7 @@

long clientLastModified = httpRequest.getDateHeader("If-Modified-Since"); // will return -1 if no header...

- if (clientLastModified >= respContent.getLastModified()) {
+ if (( clientLastModified != -1 ) && ( clientLastModified >= respContent.getLastModified())) {
                 ((HttpServletResponse) response).setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                 return;
             }


 All   Comments   Change History      Sort Order:
Andres March - [20/Jan/05 05:26 PM ]
applied patch to cvs

Lars Torunski - [27/Jan/05 04:33 PM ]
works fine, no blank page anymore

Lars Torunski - [19/Apr/05 02:05 PM ]
After a cache object is expired the browser or the web server is sending a wrong http header "Last-Modified" or "If-Modified-Since".

Lars Torunski - [19/Apr/05 03:23 PM ]
The last modified value in the ResponseContent is set to the object creation time now and not "-1".

Lars Torunski - [20/Apr/05 03:29 AM ]
The filter is sending a

Last-Modified: Wed, 31 Dec 1969 23:59:59 GMT

which is incorrect. The header "Last-Modified" shouldn't be included, if the last modified value is "-1".