You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by swoodbury <sw...@att.net> on 2010/08/05 22:42:25 UTC

tomcat caching of static files

Hi.

I have a tomcat - struts web application.

I have a thread which creates a static datafile each night.   when the user
accesses the corresponding .do action, that action reads the static file and
presents formatted output.  if the file isn't there for whatever reason, it
creates it dynamically and then presents the formatted output (still by
reading the file it just created).  

My problem is that the nightly re-creation works fine, i can see changes in
the file, and the mod time of the file is updated.  but Tomcat is evidently
caching the old contents because the old content is still presented to the
user.  But if i remove the static file and thus force the action to
re-create it, the new data is presented to the user.  things also work if i
manually edit the file (say with vi) and save it, the user again gets
updated information.  but if the thread creates the data, the action never
sees it.

Also, both the thread and the action call the same method when generating
the static data.

any ideas?
-- 
View this message in context: http://old.nabble.com/tomcat-caching-of-static-files-tp29356390p29356390.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: tomcat caching of static files

Posted by Karthik Nanjangude <ka...@xius-bcgi.com>.
Hi

Try using the CACHE Filter technique

URL : http://code.google.com/p/cache-filter/



With regard
karthik

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: Saturday, August 07, 2010 9:54 PM
To: Tomcat Users List
Subject: RE: tomcat caching of static files

> From: swoodbury [mailto:swoodbury@att.net]
> Subject: Re: tomcat caching of static files
>
> So the only thing left as far as i can see is the tomcat
> server caching the file in memory and not noticing the
> timestamp change when the thread re-creates the file.

Or some intermediary device between the client and server.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: tomcat caching of static files

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: swoodbury [mailto:swoodbury@att.net]
> Subject: Re: tomcat caching of static files
> 
> So the only thing left as far as i can see is the tomcat 
> server caching the file in memory and not noticing the
> timestamp change when the thread re-creates the file.

Or some intermediary device between the client and server.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat caching of static files

Posted by swoodbury <sw...@att.net>.


Are you sure it's Tomcat doing the caching?  I've found that both Firefox
and IE will cache CGI, JSP, servlet, and other dynamic results.  

yes, i'm approaching certain that it isn't a browser issue.  If i delete the
static files and thus force the system to regen i get updated data, but the
url etc is identical as far as the browser is concerned.  it's only if the
thread causes the regen that the action doesn't know and uses old data.  If
i hand-edit the static file, i also get updated data.  there again the url
etc that the browser sees is identical.  So the only thing left as far as i
can see is the tomcat server caching the file in memory and not noticing the
timestamp change when the thread re-creates the file.

very strange.
-- 
View this message in context: http://old.nabble.com/tomcat-caching-of-static-files-tp29356390p29375144.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat caching of static files

Posted by Thad Humphries <th...@gmail.com>.
Are you sure it's Tomcat doing the caching?  I've found that both Firefox
and IE will cache CGI, JSP, servlet, and other dynamic results.  This has
been true going back to when the old Mozilla 1.x had a preference for
*never* caching.

For GET calls were the results underlying content might change and the
browser not see it, I've taken to adding a bozo param just so the URL is
different:  myServlet+"?..."+"&bozo=" + System.currentTimeMillis()

On Thu, Aug 5, 2010 at 4:42 PM, swoodbury <sw...@att.net> wrote:

>
> Hi.
>
> I have a tomcat - struts web application.
>
> I have a thread which creates a static datafile each night.   when the user
> accesses the corresponding .do action, that action reads the static file
> and
> presents formatted output.  if the file isn't there for whatever reason, it
> creates it dynamically and then presents the formatted output (still by
> reading the file it just created).
>
> My problem is that the nightly re-creation works fine, i can see changes in
> the file, and the mod time of the file is updated.  but Tomcat is evidently
> caching the old contents because the old content is still presented to the
> user.  But if i remove the static file and thus force the action to
> re-create it, the new data is presented to the user.  things also work if i
> manually edit the file (say with vi) and save it, the user again gets
> updated information.  but if the thread creates the data, the action never
> sees it.
>
> Also, both the thread and the action call the same method when generating
> the static data.
>
> any ideas?
> --
> View this message in context:
> http://old.nabble.com/tomcat-caching-of-static-files-tp29356390p29356390.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v, 121-24)