Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > About Cache-Control, Tomcat filters and browsers...

Reply
Thread Tools

About Cache-Control, Tomcat filters and browsers...

 
 
ENRIQUE
Guest
Posts: n/a
 
      04-17-2007
Hi,

Since tomcat doesn't provide any hint about cache policies for
images, javascripts and other static files I created a filter for
those files that read like:

public class filterCacheControl implements Filter {
...
public void doFilter(ServletRequest request, ServletResponse
response, FilterChain chain) throws IOException, ServletException {
((HttpServletResponse)response).addHeader("Expires ", "Thu, 1 Jan
2099 23:59:59 GMT");
((HttpServletResponse)response).addHeader("Cache-Control", "max-
age=600");
((HttpServletResponse)response).addHeader("Last-Modified", "Thu, 1
Jan 1970 00:00:00 GMT");
chain.doFilter(request, response);
}
...
}

The filter works as expected and add the Cache-Control to the HTTP
header.

The problem is that the browser "neglects" it and tries to reload the
files once and once again. The network capture shows next HTTP
conversation:

GET /src/event/common.js HTTP/1.1 <-- Browser request

Host: osiris:8080

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/
20070310 Iceweasel/2.0.0.3 (Debian-2.0.0.3-2)

Accept: text/xml,application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Accept-Language: es,en;q=0.7,en-us;q=0.3

Accept-Encoding: gzip,deflate

Accept-Charset: UTF-8,*

Keep-Alive: 300

Connection: keep-alive

Referer:
http://osiris:8080/Controller?formAc...6&formHora2=18

Cookie: JSESSIONID=ED268E69F6A0993BB152ABDC7545A433

If-Modified-Since: Tue, 17 Apr 2007 09:50:44 GMT

If-None-Match: W/"28830-1176803444000"

Cache-Control: max-age=0



HTTP/1.1 304 Not Modified <-- Tomcat response

Expires: Thu, 1 Jan 2099 23:59:59 GMT

Cache-Control: max-age=600

Last-Modified: Thu, 1 Jan 1970 00:00:00 GMT

Date: Tue, 17 Apr 2007 15:30:14 GMT

Server: Apache-Coyote/1.1



a few seconds later:

GET /src/event/common.js HTTP/1.1 <-- Why????? The browser already
knew the common.js expires on 2099, the Cache-Control has a max-age of
600 seconds, and it wasn't modifyied since 1970.

.....

Thanks in advance for any help, hint or link!!!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Stacked polariser filters instead of ND filters? peter Digital Photography 5 12-13-2010 10:25 PM
using the Filters DLL (image filters) Dieter Vanderelst Python 1 02-15-2006 09:56 AM
Filters, Struts Actions, and Tomcat rjweytens Java 0 06-30-2004 10:04 PM
Filters, Struts Actions, and Tomcat rjweytens Java 0 06-30-2004 08:48 PM
Canon: EF filters = EF-S filters? [blu|shark] Digital Photography 17 01-28-2004 10:04 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57