Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [hudson-dev] Access to static resources - Solved

OK this turns out to be a pretty simple one to solve and I'll update the Wiki accordingly in a second.
The problem is not with Apache or Hudson, it's specifically with  Tomcat when it is secured. In this circumstance Tomcat explicitly adds a cache-control: no-cache to all the responses and although Hudson has set the expires time for a year this is then suppressed / ignored because of this.
The solution is a minor change to the Tomcat server.xml which will switch off this behavior and therefore allow Hudson's own cache management which is handled by the hudson.ResponseHeaderFilter.
Here's the change (the valve) which I've implemented at ci.hudson-ci.org:

<Context path=""
         docBase="${catalina.home}/hudson"
         reloadable="false"
         useHttpOnly="true">
 <Valve className="org.apache.catalina.authenticator.NonLoginAuthenticator"
        disableProxyCaching="false" />
</Context>
Duncan


On 06/03/2012 19:14, Manfred Moser wrote:
Typically you would set it up as a reverse proxy and it should cache static resource transparently.

I would have thought that for a bigger Hudson instance front with Apache or nginx or so is a best practice anyway.

manfred

On 12-03-06 11:11 AM, Winston Prakash wrote:
Both ci.hudson-ci.org and hudson.eclipse.org are issuing the static resources for every request (200 OK , instead of 304 Not Modified for the refresh) . Interestingly at both places Hudson is fronted by Apache proxy. Not sure if some kind of settings needed in Apache to set the caching correctly.

- Winston

On 3/5/12 10:50 AM, Henrik Lynggaard Hansen wrote:
HI

As talked about in todays call,  I think that hudson is correctly
setting the expires for static resources. In order to verify this I
cleared my cache and enabled access logging on my desktop hudson. All
tests done with firefox 3.6.16

For a static resource on first request I get

Request:
(Request-Line)    GET /static/9562870d/images/16x16/health-80plus.gif HTTP/1.1
Host    localhost:7070
User-Agent    Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.16)
Gecko/20110322 Fedora/3.6.16-1.fc14 Firefox/3.6.16
Accept    image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language    en,da;q=0.5
Accept-Encoding    gzip,deflate
Accept-Charset    UTF-8,*
Keep-Alive    115
Connection    keep-alive
Referer    http://localhost:7070/
Cookie    nailsSessionId=127.0.0.1/nails/1308561967/1308561635-checksum//0;
ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE=aGVucmlrOjEzMzE4MTg1MzIxNTc6N2E2NGMyYThhNmFiYTkxNzE1MTA5N2U3ZWNiZjYwOTE=;
screenResolution=1920x1095

Response:
(Status-Line)    HTTP/1.1 200 OK
Server    Winstone Servlet Engine v0.9.10
Last-Modified    Thu, 01 Mar 2012 09:45:01 GMT
Expires    Tue, 05 Mar 2013 18:33:26 GMT<<<<<<<<<<<<  Note the expires header
Accept-Ranges    bytes
Content-Type    image/gif
Content-Length    553
Connection    Keep-Alive
Date    Mon, 05 Mar 2012 18:33:26 GMT
X-Powered-By    Servlet/2.5 (Winstone/0.9.10)

When I then try to reload the page by navigating the url again I get
(and no hit in the hudson access log)
00:01:50.135    0.637    642    (7577)    GET    (Cache)    application/_javascript_    http://localhost:7070/static/9562870d/scripts/yui/button/button-min.js

But if I press the refresh button I get a hit on hudson (but I am
asking the browser to revalidate the page)

Request
(Request-Line)    GET /static/9562870d/scripts/hudson-behavior.js HTTP/1.1
Host    localhost:7070
User-Agent    Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.16)
Gecko/20110322 Fedora/3.6.16-1.fc14 Firefox/3.6.16
Accept    */*
Accept-Language    en,da;q=0.5
Accept-Encoding    gzip,deflate
Accept-Charset    UTF-8,*
Keep-Alive    115
Connection    keep-alive
Referer    http://localhost:7070/
Cookie    nailsSessionId=127.0.0.1/nails/1308561967/1308561635-checksum//0;
ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE=aGVucmlrOjEzMzE4MTg1MzIxNTc6N2E2NGMyYThhNmFiYTkxNzE1MTA5N2U3ZWNiZjYwOTE=;
screenResolution=1920x1095;
JSESSIONID=385adea4d8ebfcae10629196af08a6d0
If-Modified-Since    Thu, 01 Mar 2012 09:45:01 GMT
Cache-Control    max-age=0

Response:
(Status-Line)    HTTP/1.1 304 Not Modified
Server    Winstone Servlet Engine v0.9.10
Content-Length    0
Connection    Keep-Alive
Content-Type    text/html;charset=ISO-8859-1
Date    Mon, 05 Mar 2012 18:44:58 GMT
X-Powered-By    Servlet/2.5 (Winstone/0.9.10)

Best regards
Henrik
_______________________________________________
hudson-dev mailing list
hudson-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/hudson-dev


 

Back to the top