Search squid archive

Re: Squid Reverse Proxy (accel) always contacting the server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/30/2012 01:47 AM, Daniele Segato wrote:
Hi,

This is what I want to obtain:

Environment:
* everything on the same machine (Debian GNU\Linux)
* server running on tomcat, port 8080
* squid running on port 280
* client can be anywhere, but for now it's on the localhost machine too

I want to set up an http cache to my tomcat server to reduce the load on
it.


[...]

Instead squid is ALWAYS requiring the resource to the server:
$ curl -v -H 'If-Modified-Since: Thu, 29 Mar 2012 22:14:20 GMT'
'http://localhost:280/alfresco/service/catalog/products'



To help others who stumble into this issue.

On your server:

Make sure you are formatting your response http headers correctly (I had a Last-Modified date formatting which wasn't compliant to the RFC2822 and was writing +0000 in the place of GMT, resulting in squid always returning TCP_MISS)

I provided this http headers in response:

Last-Modified: <date here, should change when the content change>
Cache-Control: public, max-age=60

60 = 60 seconds, means: squid please do not bother the server for 60 seconds after this reply, even if they ask for "If-Modified-Since"

I also added s-maxage but probably it's not needed unless you want to cache authenticated contents.

Vary: <request header that may vary your response>
This is very important if you are providing a different result by request headers (for example a content in English for Accept-Language: en, and a content in Italian for Accept-Language: it)

I also added Age: 0 (i tell squid that I'm providing a fresh content).
And Date: with the current date, I think this also tells squid the content is fresh
not sure those are needed but probably helps.


On the squid size I configured the refresh_pattern <regex> 0 20% 4320

without adding any other option, this was perfectly fine.

I hope this will help anybody else with this issue :)

Squid is great! and allowed me to provide a very responsive and scalable service out of a simple non-clustered server

regards,
Daniele


[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux