Re: [squid-users] Re: Squid Reverse Proxy (accel) always contacting the server

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Mon, 02 Apr 2012 13:22:55 +1200

On 02.04.2012 07:35, Daniele Segato wrote:
> 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.
>

With a few extra notes...

> 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"

Small correction: means don't ask again until 60 seconds from
Last-Modified. If Last-Modified is missing or invalid, 60 seconds from
Date:.

>
> 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.

Tells when the response was generated, in case of transfer delays. Acts
as a backup for Last-Modified as above, and a value to synchronise
Expires: comparisons between proxies and servers despite any clock
difference problems.

>
>
> On the squid size I configured the refresh_pattern <regex> 0 20% 4320
>
> without adding any other option, this was perfectly fine.

refresh_pattern provides default values for max-age / min-age and next
revalidate time if none are provided by the combination of cache control
headers discussed above. When Expires: or Cache-Control: are sent
refresh_pattern value is not used.

>
> 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
Received on Mon Apr 02 2012 - 01:22:59 MDT

This archive was generated by hypermail 2.2.0 : Mon Apr 02 2012 - 12:00:02 MDT