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 1/04/2012 3:53 a.m., Daniele Segato wrote:
On 03/31/2012 05:01 PM, Daniele Segato wrote:
On 03/31/2012 10:13 AM, Amos Jeffries wrote:
max-age

The max-age response directive indicates that the response is to
be considered stale after its age is greater than the specified
number of seconds.

"

The logic goes like this:

Object modified ... 22:14:20
Valid +3600
==> fresh until 23:14:50
Current time: 23:27:57

23:14:50 < 23:27:15 ==> currently stale. must revalidate.

Expires header can be used to set an absolute time for invaldation.
max-age is relative to age.

Ok I think I now understood you...


you are saying that max-age is added to "last modified date"
but that doesn't make much sense to me.

If the server (parent cache) is returning the content at 23:27:00 saying
max-age 3600 I would expect that 3600 start from "now".


anyway, I thought about this before and I also tried to modify the
content, then immediately giving two request to squid.

apparently this was caused by a mistake I did with the server (see below)


this time, suppose:

Object modified ... 00:00:00
Valid +3600
==> fresh until 01:01:00
Current time: 00:05:00

01:01:00 > 00:05:00 ==> currently fresh. shouldn't bother the server.

instead what's actually happening is that squid is doing a request to my
server, only header, but it's still doing it.

My server, to compute the "Last-Modified" date has to do all the job of
collecting the data, looping to each data element and extract, for each,
the last modified date, then compute the "last one".. it build a "model"
that is then rendered: it's pretty short anyway since it's gzipped text.

So the big work of my server is to collect the data, and my server have
to do it both if you do a GET both if you do an HEAD request.

I would like squid to revalidate with my server every, say 1 minute,
even 10 seconds is ok.. but it shouldn't revalidate every single request
it is receiving.

I hope I made my point.


this question is still in place :)


revalidation is more of a threshold which gets set on each object. Under the threshold no valdation takes place, above it every request gets validated. BUT ... a 304 response revalutating the object can change the threshold by sending new timestamp and caching headers.



I wanted to give you an example but now squid is always giving me a
TCP_MISS

this was my mistake, the Last-Modified date format was wrong from server :)

please ignore the debug and everything behind this point in my previous email...

Now it's giving cache hits in ram!


I think I can summarize my question in this two questions:
1) can I make squid3 update the cache with my server every, say, 1 minute (at most) but use it's cache otherwise without bothering the server (not even for headers)? how?

Avoiding to call the server for 1 hour, I think, it's a bit too much: the content can change in the meanwhile and I don't want the user to wait 1 hour for it.

On the other part I don't want every single request after that hour is pass to see squid contacting my server to check if the last modified date is changed.


You have the two options of max-age or Expires. The thing to remember is to increment the value / threshold forward to the next poitn where you want revalidation to take place.

with a max-age N value which you generate dynamically by: calculate current age of object when responding, add 60.

with Expires: you simply emit a timestamp of now() + 60 seconds on each response.

Other useful things to know;
Generating an ETag label for each unique output helps caches detect unique versions without timestamp calculations. The easy ways to do this are to make ETag a MD5 hash of the body object. Or a hash of the Last-Modified timestamp string if the body is too expensive to locate MD5 for. Or some other property of the resource which is guaranteed to change any time the body changes and not otherwise.

Cache-Control:stale-while-revalidate tells caches to revalidate, but not to block the client response waiting for that validation to finish. Clients will get the old object until a new one or 304 is received back.



2) which is the best way to debug why squid3 is deciding to keep a cache entry, contact the server or not? looking at the huge debug log is not very simple maybe some log option to filter it with the cache decisions informations only would help

debug_options 22,3
... or maybe 22,5 if there is not enough at level 3.

Amos


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

  Powered by Linux