[squid-users] Looking to trigger reply_on_error with custom header

Alex Rousskov rousskov at measurement-factory.com
Mon Nov 7 17:24:28 UTC 2016


On 11/07/2016 08:48 AM, Daniel Dormont wrote:

> the request will return a 200 OK, and the response body
> will be a valid image, but it'll have this extra header:
> 
> x-staticmap-api-warning:Failed to fetch image url
> http://download.example.com/mapicons/1
> 
> This should be a transient error, so what I'd like to do is use
> Squid's retry_on_error option to have it just silently fetch the
> upstream image again, but customize what "error" means in this case to
> handle this extra header that Google sends in what's otherwise a 200
> Ok response.
> 
> Unfortunately I'm not all that familiar with Squid at this point. Is
> such a thing even possible? If so, where would I begin?


As you probably know, Squid already has logic to determine which failed
transactions should be retried or reforwarded[1]. That logic is
currently mostly hard-coded. Your options include:

1. Adding a new ACL-driven squid.conf directive to control hard-coded
retry/reforward decisions. This requires Squid development.

2. Using a RESPMOD adaptation service[2] to rewrite Google responses so
that Squid treats them as errors [that should be retried/reforwarded].
This requires research/experiments to confirm that Squid looks at the
adopted message when deciding whether to retry AND adaptation service
development.

[1]
http://wiki.squid-cache.org/SquidFaq/InnerWorkings#When_does_Squid_re-forward_a_client_request.3F

[2] http://wiki.squid-cache.org/SquidFaq/ContentAdaptation


HTH,

Alex.



More information about the squid-users mailing list