Actually, I've thought better of getting in the way of all the redirects. I can just hand all the objects back to the clients and let varnish cache objects as they go past. It just works.
On Sun, Aug 30, 2009 at 11:11 PM, David Birdsong<[email protected]> wrote: > I'm trying to wrap my brain around the VCL needed to do what I'm > thinking of, but it'd be helpful to know up front if what I'm trying > to achieve isn't possible. > > I'm hoping to provide a backend of last resort for certain types of > requests for the cases of > 1. an actual down backend > 2. where obj.status != 200 && req.request == "GET" && req.url ~ > "\.(gif|jpg|swf|css|js|png|jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|css|js|vsd|doc|ppt|pps|xls|pdf|mp3|mp4|m4a|ogg|mov|avi|wmv|sxw|zip|gz|bz2|tgz|tar|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm) > > #2 means i can't rely on probes to set my backend to the backend of last > resort. > > here's the pertinent vcl vcl_fetch > > sub vcl_fetch { > # force minimum ttl of 300 seconds > if (obj.ttl < 604800s) { > set obj.ttl = 604800s; > } > if (obj.status != 200) > if (req.restarts > 0) { > deliver; > } > if (req.request == "GET" && req.url ~ > "\.(gif|jpg|swf|css|js|png|jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|css|js|vsd|doc|ppt|pps|xls|pdf|mp3|mp4|m4a|ogg|mov|avi|wmv|sxw|zip|gz|bz2|tgz|tar|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$") > { > restart; > } else { > deliver; > } > } > } > > sub vcl_recv { > if (req.restarts == 0) { > if (req.http.host ~ "^img3\.(.*)$") { > set req.backend = b0; > } else { > error 750 "invalid host header"; > } > } > if (req.request == "GET" && req.url ~ > "\.(gif|jpg|swf|css|js|png|jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|css|js|vsd|doc|ppt|pps|xls|pdf|mp3|mp4|m4a|ogg|mov|avi|wmv|sxw|zip|gz|bz2|tgz|tar|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$") > { > if (! req.backend.healthy && req.restarts == 0) { > set req.backend = last_resort_backend; > } > lookup; > } > lookup; > } > > I'm able to get varnish to re-send a failed request to > last_resort_backend. I'm still working on the necessary VCL to follow > the 2 redirects that the last_resort_backend will send -I'd like > varnish to complete these and not pass them on to the client. > > What I'd like to do is instruct it to cache the static file under the > original url, not the url of the last 302. > > My inexperience using varnish has me thinking about having to set the > req.url for first the 301 and then again for the 302 combined with > restarts, but this made me think that I'd have to store the original > url somewhere and set it again. Is this type of thing possible? > > Apologies if this is not clear. > _______________________________________________ varnish-misc mailing list [email protected] http://projects.linpro.no/mailman/listinfo/varnish-misc
