You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Stefan Riegel <st...@telig.de> on 2007/01/18 00:57:36 UTC
Cache problems with static resources
Hello all,
we are using Apache Tomcat 5.5.16 on both a Windows (development) and
Linux (production) system. Caching of static resources works fine but we
should control the behavior. We use a filter, which transforms static
xml files and inserts some data.
The access log shows clearly that all static resources are cached.
127.0.0.1 - don [18/Jan/2007:00:04:58 +0100] "GET /hospi2007/index.xms?
HTTP/1.1" 304 -
127.0.0.1 - don [18/Jan/2007:00:04:58 +0100] "GET
/hospi2007/stylesheet.jsp? HTTP/1.1" 200 1429
127.0.0.1 - don [18/Jan/2007:00:04:58 +0100] "GET /hospi2007/leftbg.gif?
HTTP/1.1" 304 -
The XSLT filter did manipulate the xml content from the "index.xms" but
of course nothing shows up in Mozilla 2.0.0.1. Better said: it did not
manipulate anything because the writer (a char buffer) of the wrapped
response does not contain anything. (By the way. With the latest IE it
is nothing caching at all and everything works as expected).
Don't worry about our special filter implementation. The caching appears
already with simple HTML pages which does not pass the filter:
127.0.0.1 - don [18/Jan/2007:00:26:31 +0100] "GET /hospi2007/index.html?
HTTP/1.1" 304 -
And exactly here we would like to disable the caching.
Meta tags did not help:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META content="no-cache" http-equiv="pragma" >
<META content="no-cache, must-revalidate" http-equiv="Cache-Control" >
<META content="0" name="Expires" >
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Context configuration did not help neither:
<Context cacheMaxSize="1" cacheTTL="1" cachingAllowed="false"
reloadable="true">
We thought about changing the request header "if-modified-since"
somewhere in the XSLT filter, but did not find a way to do this.
We thought even about to substitute the static xml pages with jspx
pages. This works fine, but we got problems with the "&" entity. Jsp
substitutes the entities with "&" which breaks the XML.
Any suggestion for a clean and simple solution?
Regards
Stefan
--
Stefan
---------------------------------------------------------------------
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: Cache problems with static resources
Posted by Stefan Riegel <st...@telig.de>.
Gregor Schneider schrieb:
> yes. simply don't use meta-tags, since according to some rfc browsers
> do not have to interprete them.
>
> use http-headers instead, simples as:
>
> Expires: (Actual date - 1 month)
>
> Write a filter that modifies the headers of each response.
>
> Worked for us, although it was the otehr way round (we wanted to
> browsers to cache).
>
> Cheers
>
> Greg
Thank you Greg,
I tried this:
Sending a last-modified header from 1970 in the response. Mozilla
started sending this old date in the if-modified-since header. But
Tomcat is still caching. No good.
I played with modifying the etag and if-none-match response headers.
Still caching.
Anything else I could modify? But the main question for me is still:
"why does tomcat ignore all the context attributes regarding caching?"
<Context cacheMaxSize="1" cacheTTL="1" cachingAllowed="false" />
No effect at all. Why? Very strange for me.
Does anybody succeed with that?
Regards
Stefan
--
Stefan
---------------------------------------------------------------------
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: Cache problems with static resources
Posted by Gregor Schneider <rc...@googlemail.com>.
yes. simply don't use meta-tags, since according to some rfc browsers
do not have to interprete them.
use http-headers instead, simples as:
Expires: (Actual date - 1 month)
Write a filter that modifies the headers of each response.
Worked for us, although it was the otehr way round (we wanted to
browsers to cache).
Cheers
Greg
--
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371
---------------------------------------------------------------------
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: Cache problems with static resources
Posted by Stefan Riegel <st...@telig.de>.
Stefan Riegel schrieb:
> Hello all,
>
> we are using Apache Tomcat 5.5.16 on both a Windows (development) and
> Linux (production) system. Caching of static resources works fine but
> we should control the behavior. We use a filter, which transforms
> static xml files and inserts some data.
>
> The access log shows clearly that all static resources are cached.
>
> 127.0.0.1 - don [18/Jan/2007:00:04:58 +0100] "GET
> /hospi2007/index.xms? HTTP/1.1" 304 -
> 127.0.0.1 - don [18/Jan/2007:00:04:58 +0100] "GET
> /hospi2007/stylesheet.jsp? HTTP/1.1" 200 1429
> 127.0.0.1 - don [18/Jan/2007:00:04:58 +0100] "GET
> /hospi2007/leftbg.gif? HTTP/1.1" 304 -
>
> The XSLT filter did manipulate the xml content from the "index.xms"
> but of course nothing shows up in Mozilla 2.0.0.1. Better said: it did
> not manipulate anything because the writer (a char buffer) of the
> wrapped response does not contain anything. (By the way. With the
> latest IE it is nothing caching at all and everything works as expected).
>
> Don't worry about our special filter implementation. The caching
> appears already with simple HTML pages which does not pass the filter:
>
> 127.0.0.1 - don [18/Jan/2007:00:26:31 +0100] "GET
> /hospi2007/index.html? HTTP/1.1" 304 -
>
> And exactly here we would like to disable the caching.
>
> Meta tags did not help:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> <META content="no-cache" http-equiv="pragma" >
> <META content="no-cache, must-revalidate" http-equiv="Cache-Control" >
> <META content="0" name="Expires" >
> <title>Hello World</title>
> </head>
> <body>
> <h1>Hello World</h1>
> </body>
> </html>
>
> Context configuration did not help neither:
>
> <Context cacheMaxSize="1" cacheTTL="1" cachingAllowed="false"
> reloadable="true">
>
> We thought about changing the request header "if-modified-since"
> somewhere in the XSLT filter, but did not find a way to do this.
>
> We thought even about to substitute the static xml pages with jspx
> pages. This works fine, but we got problems with the "&" entity.
> Jsp substitutes the entities with "&" which breaks the XML.
>
> Any suggestion for a clean and simple solution?
>
> Regards
> Stefan
>
Hi Chris,
the HTML META tags above do not change the browsers request behavior at
all. Their must be something strange with tomcats caching or with the
mozilla requests. Is it something wrong with my context attributes
above? With this configuration, tomcat should not cache static resources
(see http://tomcat.apache.org/tomcat-5.5-doc/config/context.html).
Thunderbird request headers with and without the META tags above:
host: localhost:8080
user-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.1)
Gecko/20061204 Firefox/2.0.0.1
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: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
accept-encoding: gzip,deflate
accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
keep-alive: 300
connection: keep-alive
if-modified-since: Wed, 17 Jan 2007 22:56:34 GMT
if-none-match: W/"1242-1169074594484"
authorization: Basic ZG9uOmVzdGViYW4=
cache-control: max-age=0
MS IE 7.0 request headers without the META tags above:
accept: */*
accept-language: de
ua-cpu: x86
accept-encoding: gzip, deflate
user-agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1)
host: localhost:8080
connection: Keep-Alive
cookie: JSESSIONID=1964AE122DC80DBC7A692B4FC1941343
authorization: Basic ZG9uOmVzdGViYW4=
First, I suspected the if-modified-since header to control the caching.
So I did send a last-modified header from 1970 in the response. Mozilla
does a good job and started sending this old date in the
if-modified-since header. But Tomcat is still caching. Nogood.
Second, I played with modifying the etag and if-none-match respons
headers. Still caching.
Very strange. Their must be a simple method to prevent caching
regardless of browser requests. Any idea?
Thank you
Stefan
--
Stefan
---------------------------------------------------------------------
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: Cache problems with static resources
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Stefan,
Stefan Riegel wrote:
> The caching appears already with simple HTML pages which does not
> pass the filter:
>
> 127.0.0.1 - don [18/Jan/2007:00:26:31 +0100] "GET /hospi2007/index.html?
> HTTP/1.1" 304 -
>
> And exactly here we would like to disable the caching.
>
> Meta tags did not help:
Actually, the META tags /are/ probably helping: the browser /is/ going
to the server as you instructed it (otherwise, you wouldn't have the 304
status codes in your log file).
META tags are instructions for the browser, not the server.
Sorry I can't give you any ideas beyond what you've already tried on the
server side, but its worth noting that the browser is neither your
problem nor the place to look for a solution.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFrwdd9CaO5/Lv0PARAt2tAKCqZoCRqEJ3UTTMwY2IjOmaSRSEMwCdHCZr
N7DukuPDxxwoGUWVK9++91A=
=C4n6
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
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