You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Mok <jm...@attglobal.net> on 2006/10/01 02:45:30 UTC
HOWTO disable Tomcat from caching dynamic picture
Hi,
I am using Tomcat 5.5.17 with Sun JDK 5.0 Update 7 on CentOS 4.3. I have
a servlet, namely BMPImageViewer, which retrieves a BMP image from
database with conversion into PNG format via JAI. The servlet is
referenced in XSL-FO for PDF generation.
My problem was that the image did not change even the image in database
updated. I checked that the servlet BMPImageViewer worked correctly and
loaded the correct image every time. The servlet outputs the image with
header set to "no-cache" :-
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", -1);
How to force Tomcat not to cache the dynamic image? and load a new one
every time? I hope someone could help me out and advise how to configure
Tomcat not to cache dynamic image.
Thanks a lot.
John Mok
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: HOWTO disable Tomcat from caching dynamic picture
Posted by Martin Gainty <mg...@hotmail.com>.
left out setDateHeader
response.setDateHeader("Expires", 1);
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
Not much to recommend until we see the code which does the conversion (assuming JPG to PNG)
Anyone else ?
Martin --
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed. If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy. Thank you.
----- Original Message -----
From: "david.delbecq" <da...@oma.be>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Sunday, October 01, 2006 5:47 AM
Subject: Re: HOWTO disable Tomcat from caching dynamic picture
> Tomcat does not cache output of a servlet. By definition the output of a
> servlet is dynamic and as such has no reason to be cached. The image is
> probably cached somewhere else...
> John Mok a écrit :
>> Hi,
>>
>> I am using Tomcat 5.5.17 with Sun JDK 5.0 Update 7 on CentOS 4.3. I
>> have a servlet, namely BMPImageViewer, which retrieves a BMP image
>> from database with conversion into PNG format via JAI. The servlet is
>> referenced in XSL-FO for PDF generation.
>>
>> My problem was that the image did not change even the image in
>> database updated. I checked that the servlet BMPImageViewer worked
>> correctly and loaded the correct image every time. The servlet outputs
>> the image with header set to "no-cache" :-
>>
>> response.setHeader("Pragma", "no-cache");
>> response.setHeader("Expires", -1);
>>
>> How to force Tomcat not to cache the dynamic image? and load a new one
>> every time? I hope someone could help me out and advise how to
>> configure Tomcat not to cache dynamic image.
>>
>> Thanks a lot.
>>
>> John Mok
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: HOWTO disable Tomcat from caching dynamic picture
Posted by "david.delbecq" <da...@oma.be>.
Tomcat does not cache output of a servlet. By definition the output of a
servlet is dynamic and as such has no reason to be cached. The image is
probably cached somewhere else...
John Mok a écrit :
> Hi,
>
> I am using Tomcat 5.5.17 with Sun JDK 5.0 Update 7 on CentOS 4.3. I
> have a servlet, namely BMPImageViewer, which retrieves a BMP image
> from database with conversion into PNG format via JAI. The servlet is
> referenced in XSL-FO for PDF generation.
>
> My problem was that the image did not change even the image in
> database updated. I checked that the servlet BMPImageViewer worked
> correctly and loaded the correct image every time. The servlet outputs
> the image with header set to "no-cache" :-
>
> response.setHeader("Pragma", "no-cache");
> response.setHeader("Expires", -1);
>
> How to force Tomcat not to cache the dynamic image? and load a new one
> every time? I hope someone could help me out and advise how to
> configure Tomcat not to cache dynamic image.
>
> Thanks a lot.
>
> John Mok
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: HOWTO disable Tomcat from caching dynamic picture
Posted by Christopher Schultz <ch...@christopherschultz.net>.
John,
> I have a servlet, namely BMPImageViewer, which retrieves a BMP image
> from database with conversion into PNG format via JAI. The servlet is
> referenced in XSL-FO for PDF generation.
Do you use Cocoon or something similar to do the XSL-FO->PDF conversion?
If so, do you have caching turned on in that pipeline?
Just a thought.
-chris
RE: HOWTO disable Tomcat from caching dynamic picture
Posted by Paul Hamer <pa...@tohave.nl>.
Hey John,
Tomcat does not do any caching. Try adding these HTTP headers:
response.addHeader("Pragma","no-cache"); // HTTP/1.0
response.addHeader("Cache-control","no-cache, no-store"); // HTTP/1.1
That's the official way. However, due to an IE4-IE6 bug, you might want to
replace the second one by:
response.setHeader("Cache-control","max-age=0"); // HTTP/1.1
More info see: http://forum.java.sun.com/thread.jspa?threadID=233446&start=0
Worked fine for me!
Regards,
Paul Hamer
management & development
paul@tohave.nl
toHAVE websolutions
www.tohave.nl
info@tohave.nl
> -----Original Message-----
> From: John Mok [mailto:jmok@attglobal.net]
> Sent: Sunday, 01 October 2006 02:46
> To: users@tomcat.apache.org
> Subject: HOWTO disable Tomcat from caching dynamic picture
>
> Hi,
>
> I am using Tomcat 5.5.17 with Sun JDK 5.0 Update 7 on CentOS
> 4.3. I have
> a servlet, namely BMPImageViewer, which retrieves a BMP image from
> database with conversion into PNG format via JAI. The servlet is
> referenced in XSL-FO for PDF generation.
>
> My problem was that the image did not change even the image
> in database
> updated. I checked that the servlet BMPImageViewer worked
> correctly and
> loaded the correct image every time. The servlet outputs the
> image with
> header set to "no-cache" :-
>
> response.setHeader("Pragma", "no-cache");
> response.setHeader("Expires", -1);
>
> How to force Tomcat not to cache the dynamic image? and load
> a new one
> every time? I hope someone could help me out and advise how
> to configure
> Tomcat not to cache dynamic image.
>
> Thanks a lot.
>
> John Mok
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org