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

Daniel Dormont dan at greywallsoftware.com
Mon Nov 7 15:48:44 UTC 2016


Hi,

My team uses Squid to proxy and cache certain external content in our
web platform. Now, we are looking to use it to cache images that come
from the Google Static Maps API. Sometimes, however, these images fail
to load properly, but unfortunately they do not respond with any of
the usual HTTP error codes. Instead, Google simply attaches a custom
header to the response:
https://developers.google.com/maps/documentation/static-maps/error-messages#warnings

So, basically, 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?

thanks,
Dan Dormont


More information about the squid-users mailing list