Re: [squid-users] Re: Stale-if-error , does it work?

From: Dingwell, Robert A. <>
Date: Fri, 27 Mar 2009 08:53:50 -0400

Iım using 2.7STABLE6 which is why Iım confused as to why itıs not working as
I thought it would. Are there any other headers that need to be set as
well in order for the header to be used? I guess the other question is am I
wrong in my assumption to how this is suppose to work? My assumption is that
if squid receives a stale-if-error cache directive it will cache that
response and then if there is an error contacting the origin server the the
cached response will be served up instead. Is that correct?

Below are the headers that are being emitted from the server I am testing

HTTP/1.1 200 OK
Date: Thu, 26 Mar 2009 13:59:36 GMT
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Content-Language: en-US
Content-Length: 384
Cache-Control: stale-if-error=300
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive

I currently expect squid to cache the content from this request.

Then I shut the origin down and the apache acting as a reverse proxy ships
back a service unavailable response.

HTTP/1.1 503 Service Temporarily Unavailable
Date: Thu, 26 Mar 2009 14:00:26 GMT
Content-Length: 323
Connection: close
Content-Type: text/html; charset=iso-8859-1

This is were I would expect squid to give me back the first request. Is this
a correct assumption?

Thanks for the help.


On 3/26/09 10:52 PM, "Amos Jeffries" <> wrote:

> Dingwell, Robert A. wrote:
>> On 3/26/09 11:01 AM, "Dingwell, Robert A. (BOBD)" <> wrote:
>>> Iıve been trying to get a caching architecture setup so that if a server I
>>> am caching content for goes down or is more likely just unavailable to do
>>> network issues I can have the cache serve up the stale content. In the
>>> production environment that this will be used I will not have the ability to
>>> have all of the services involved set cache control headers on their data.
>>> We
>>> are operating on a wan with people all over the globe so it would be really
>>> difficult to get everyone to do that. What I can do though is to make sure
>>> that everything goes through apache acting as a reverse proxy which then
>>> sets
>>> the Cache-Control header, which I have done and verified that it does indeed
>>> do what I want it to.
>>> So now I fire up squid and apache and attempt to access a server I have
>>> control over and I get back the data I expect to get back. Look in the
>>> squid
>>> log file see the header in the log ³Cache-Control: stale-if-error=300² so I
>>> know itıs being sent. Now I shutdown the server I just accessed and attempt
>>> to access the same url. I expect to get back the same data that I just got
>>> back but instead I get back the error page saying the service is
>>> unavailable.
>>> Shouldnıt squid be serving up the stale content? Or am I missing a step.
>>> The
>>> other odd thing is once I start the server back up it takes a couple of
>>> minutes to get back the page from server as squid seams to be caching the
>>> error page.
>>> I know that stale-if-error is only going to work for 500-504 errors but
>>> looking through the squid logs again I see that I am getting an error code
>>> back when I try to access the page when itıs down ³HTTP/1.1 503 Service
>>> Temporarily Unavailable².
>>> One last thing this article , ,
>>> makes it sound like squid has a configuration parameter that is used to
>>> enable
>>> stale-if-error even when the server does not send the control header. Does
>>> anyone know if this exists or what the magic incantation is to get it
>>> working?
>>> Anybody have any ideas as to what I may be doing wrong, or an alternative
>>> approach to accomplishing what I am trying to get working? I already tried
>>> using offline mode which did not work and I think isnıt really what I would
>>> want to do anyway as I need squid to attempt to access the server and serve
>>> up
>>> the stale data only when the server is down.
>>> Any help is appreciated ,
>>> Thanks
>>> Rob
> Depends.
> Squid-2.7 supports it, the others do not yet though there is a patch for
> Squid-3.1 in bugzilla awaiting someone to test it properly.
> Amos
> --
> Please be using
> Current Stable Squid 2.7.STABLE6 or 3.0.STABLE13
> Current Beta Squid
Received on Fri Mar 27 2009 - 12:53:55 MDT

This archive was generated by hypermail 2.2.0 : Mon Mar 30 2009 - 12:00:02 MDT