1
votes

I have read through several answers to this and none of them have worked. I have put a cachingAllowed in my app's META-INF/context.xml.

I have put cachingAllowed = 'false' in the server.xml and context.xml in vain. I have also deleted my work/[app] cache, this is what I'm seeing on resources coming back.

JSP - Looks good!

Request URL:/loadconf.jsp

Request Method:GET

Status Code:200 OK

Request Headers

Accept:/

Referer:http://localhost/

User-Agent:Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.59 Safari/534.3

Response Headers

Content-Type:application/javascript;charset=UTF-8

Date:Thu, 16 Sep 2010 16:52:35 GMT

Server:Apache-Coyote/1.1

Transfer-Encoding:chunked

JS - Looks bad

Request URL:yuiloader-dom-event.js

Request Method:GET

Status Code:200 OK

Request Headers

Accept:/

Referer:http://localhost/

User-Agent:Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.59 Safari/534.3

Response Headers

Accept-Ranges:bytes

Cache-Control:max-age=15552000 bad

Content-Length:60327

Content-Type:text/javascript

Date:Thu, 16 Sep 2010 16:39:57 GMT

ETag:W/"60327-1273012296000" bad

Expires:Tue, 15 Mar 2011 16:39:57 GMT bad

Last-Modified:Tue, 04 May 2010 22:31:36 GMT

Server:Apache-Coyote/1.1

1
I have to point you to @BalusC's excellent answer on this stackoverflow.com/questions/2156077/…JoseK
I would need to add a filter for every file to do this.... Why is Tomcat even assuming these files should be cached, why is it saying it should be cached xxx long. None of these parameters are specified.Drew

1 Answers

3
votes

The easy approach, use Apache, something like this:

# Configure Tomcat proxys
<VirtualHost localhost:80>

  ProxyPass / http://localhost:8080/
  ProxyPassReverse / http://localhost:8080/

  #for files that have no header
  ExpiresDefault now
  ExpiresByType text/javascript now

  #overwrite the headers tomcat is foolishly trying to provide
  Header set Cache-Control "max-age=0, must-revalidate"
  Header set Expires "January 1, 1970" #this should be "now", but it wasn't working for me

</VirtualHost>

My static files come back with 200 responses now.