Re: [squid-users] How get negative cache along with origin server error?

From: Dave Dykstra <dwd_at_fnal.gov>
Date: Tue, 07 Oct 2008 11:49:06 -0500

Henrik,

Thanks so much for your very informative reply!

On Thu, Oct 02, 2008 at 12:31:03PM +0200, Henrik Nordstrom wrote:
> By default Squid tries to use a parent 10 times before declaring it
> dead.

Ah, I never would have guessed that I needed to try 10 times before
negative_ttl would take effect for a dead host. That wouldn't be
bad at all.

I just tried this now by having two squids, one a cache_peer parent of
the other. I requested a URL while the origin server was up in order to
load the cache, with a CC max-age of 180. Both squids have max_stale 0
and negative_ttl of 3 minutes. Next, I put the origin server name as an
alias for localhost in /etc/hosts on both machines the squids were on,
so they both see connection refused when they try to connect to the
origin server. I also restarted nscd and did squid -k reconfigure to
make sure the new host name was seen by squid. After the (small) object
in the cache expired, I retried the request 20 times in a row. Every
time I still saw the request get sent from the child squid to the parent
squid and return a 504 error. This is unexpected to me; is it to you,
Henrik? I would have thought the 504 error would get cached for three
minutes after the tenth try.

> Each time Squid retries a request it falls back on the next possible
> path for forwarding the request. What that is depends on your
> configuration. In normal forwarding without never_direct there usually
> never is more than at most two selected active paths: Selected peer if
> any + going direct. In accelerator mode or with never_direct more peers
> is selected as candidates (one sibling, and all possible parents).
>
> These retries happens on
>
> * 504 Gateway Timeout (including local connection failure)
> * 502 Bad gateway
>
> or if retry_on_error is enabled also on
>
> * 401 Forbidden
> * 500 Server Error
> * 501 Not Implemented
> * 503 Service not available
>
> Please note that there is a slight name confusion relating to max-stale.
> Cache-Control: max-stale is not the same as the squid.conf directive.
>
> Cache-Control: max-stale=N is a permissive request directive, saying
> that responses up to the given staleness is accepted as fresh without
> needing a cache validation. It's not defined for responses.
>
> The squid.conf setting is a restrictive directive, placing an upper
> limit on how stale content may be returned if cache validations fail.
>
> The Cache-Control: stale-if-error response header is equivalent the
> squid.conf max-stale setting, and overrides squid.conf.

That's very good to know. I didn't see that in the HTTP 1.1 spec, but
I see that Mark Nottingham submitted a draft protocol extension with
this feature.

> The default for stale-if-error if not specified (and squid.conf
> max-stale) is infinite.
>
> Warning headers is not yet implemented by Squid. This is on the todo.

Sounds good.

- Dave
Received on Tue Oct 07 2008 - 16:52:18 MDT

This archive was generated by hypermail 2.2.0 : Wed Oct 08 2008 - 12:00:02 MDT