----- Original Message ----- From: "Joerg Endrullis" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Tuesday, September 16, 2008 1:13 PM
Subject: disable caching of static files in tomcat 5.5


Hi,

I have a dynamically generated image "a.jpg"
and I want Tomcat to always deliver the current version.

Unfortunately Tomcat seems to have some kind of caching of static files?
Where can one disable caching of static files in Tomcat?

Why do I think Tomcat has caching of static files...

You can reproduce the problem as follows:
- create two different images x.jpg and y.jpg
- then create a symbolic link from a.jpg to x.jpg, download a.jpg,
 change the symbolic link to y.jpg, download a.jpg again:

 $ ln -s x.jpg a.jpg;
 $ wget http://localhost:8180/a.jpg?time=0;
 $ rm a.jpg;
 $ ln -s y.jpg a.jpg;
 $ wget http://localhost:8180/a.jpg?time=1

You will see that both downloaded images a.jpg.1 and a.jpg.2 are equal to x.jpg,
which leads to the conclusion that Tomcat uses some kind of caching.
(in order to reproduce the problem, the commands have to be
executed fast after each other, if you wait 5 seconds before the last wget,
then Tomcat returns the correct image)

Btw. it does not help to attach an artificial time-stamp to the URL:
 $ ln -s x.jpg a.jpg;
 $ wget http://localhost:8180/a.jpg?time=0;
 $ rm a.jpg;
 $ ln -s y.jpg a.jpg;
 $ wget http://localhost:8180/a.jpg?time=1
will produce identical images a.jpg?time=0 and a.jpg?time=1.

Any help would be appreciated.

Thanks,
Joerg

Joerg, not sure here... but this is what I think is happening...
The images are been delivered to the page using ETAGS... basically they look at the file on disk size and modified time... If that changes they send it, if it does change it, nothing is sent to the browser...

It seems to imply that symboloc links are not changing these links... but I dont think linux is that stupid... So I think its just the browser hanging on.... so try this... in the main JSP servlet/html page do this...

response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "Sun, 15 Jan 1998 17:00:00 GMT");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Max-Age", 0);

In html this is all meta tags... just look em up...

Now you saying to the browser.... do not cache this page... and I'm hopng thats the images as well, and that ETAGS are not an issue with links... ie if it doesnt work... linux is showing tomcat the same modified time (doubtful) or tomcat can detect the change of the file, and does not update the etag stuff... more likely... hopefully telling the whole page not to cache gets around it...

You have to do it all those ways because MS did their own thing... as usual ;)

Have fun...
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to