tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Bottner" <kbott...@comcast.net>
Subject RE: How do you set cache-control for static (gif, jpg) resources
Date Fri, 30 Jul 2004 13:58:58 GMT


Unfortunately HttpServletResponse has now way to query the headers only to
set them and determine if they exist. However I have the RequestDumperValve
for both editions of the code. Here is the log for the 1st set of code (your
suggestions).


: ---------------------------------------------------------------
:           authType=BASIC
:      contentLength=659
:        contentType=image/gif
:             header=Pragma=No-cache
:             header=Cache-Control=no-cache
:             header=Expires=Wed, 31 Dec 1969 18:00:00 CST
:             header=ETag=W/"659-1091194009140"
:             header=Last-Modified=Fri, 30 Jul 2004 13:26:49 GMT
:            message=null
:         remoteUser=username
:             status=200
:             scheme=http
:         serverName=localhost
:         serverPort=8080
:        servletPath=/common/inject/emp-ui-bg-con-tl.gif
:           isSecure=false
: ---------------------------------------------------------------
: ---------------------------------------------------------------
:           authType=BASIC
:      contentLength=7675
:        contentType=image/gif
:             header=Pragma=No-cache
:             header=Cache-Control=no-cache
:             header=Expires=Wed, 31 Dec 1969 18:00:00 CST
:             header=ETag=W/"7675-1091194009140"
:             header=Last-Modified=Fri, 30 Jul 2004 13:26:49 GMT
:            message=null
:         remoteUser=username
:             status=200

Above you can see that none of my changes to the response stream were used.


Here is the headers for the 2nd set of code (the original)

: ---------------------------------------------------------------
: REQUEST URI       =/common/inject/emp-ui-bg-con-tl.gif
:           authType=BASIC
:  characterEncoding=null
:      contentLength=-1
:        contentType=null
:        contextPath=
:             cookie=JSESSIONIDSSO=47372C3C7BB03505C936A20970ACB1F9
:             cookie=JSESSIONID=B75E4FA2AA8047CCD40A885A0A84DFB5
:             header=accept=*/*
:             header=accept-language=en-us
:             header=accept-encoding=gzip, deflate
:             header=user-agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
:             header=host=localhost:8080
:             header=connection=Keep-Alive
:             header=authorization=Basic ZGhhbHBpbjpkaGFscGlu
:             locale=en_US
:             method=GET
:           pathInfo=null
:           protocol=HTTP/1.1
:        queryString=null
:         remoteAddr=127.0.0.1
:         remoteHost=127.0.0.1
:         remoteUser=username
: requestedSessionId=B75E4FA2AA8047CCD40A885A0A84DFB5
:             scheme=http
:         serverName=localhost
:         serverPort=8080
:        servletPath=/common/inject/emp-ui-bg-con-tl.gif
:           isSecure=false
: ---------------------------------------------------------------
: ---------------------------------------------------------------
:           authType=BASIC
:      contentLength=7675
:        contentType=image/gif
:             header=Pragma=No-cache
:             header=Cache-Control=no-cache
:             header=Cache-Control=max-age=1800
:             header=Expires=Wed, 31 Dec 1969 18:00:00 CST
:             header=Cache-Control=no-cache
:             header=Cache-Control=max-age=1800
:             header=ETag=W/"7675-1091159753343"
:             header=Last-Modified=Fri, 30 Jul 2004 03:55:53 GMT
:            message=null
:         remoteUser=username
:             status=200


Do you see the duplicate Cache-Control above? The first
Cache-control=no-cache is the default then my addition then another filter
adds the Expires and then both of the cache control lines are added again.

Thanks for the performance tip, now if I can just get this!

I appreciate any help you can offer.

Keith

-----Original Message-----

From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com] 
Sent: Friday, July 30, 2004 8:40 AM
To: Tomcat Users List
Subject: RE: How do you set cache-control for static (gif, jpg) resources



Hi,

>Previously I was calling doChain at the end of my doFilter method.
>
>Making the change you suggest, calling doChain at the top like
<snip />
>DOES NOT INSERT any of my changes into the response stream. If I do it
like
>this:
<snip />
>Then I get two additions in the response stream.
>
>Any more ideas?

That's a bit strange.  Are you wrapping the response or setting these
headers elsewhere?  Can you print out to the log a listing of all the
response headers at the end of your filter?

The addHeader method allows for multiple values, but many readers will only
see the first.  So if something in your code sets the cache-control header,
then you call it again, the header will be present twice with two values
(which is legal in the HTTP protocol for most headers).

As an aside, you can read the enumeration of the init parameters in the
filter's init method, store it in some member variable, and that will
improve the performance of your filter because you won't have to do it on
every request.

Yoav Shapira



This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.


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


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


Mime
View raw message