Deliver on HIT, otherwise redirect using "503; Location: ..."

Anton Berezhkov bubonic.pestilence at gmail.com
Sun Dec 18 01:05:48 CET 2016


Hello.

Switched to Varnish from Nginx for additional functionality and better control of handling requests.
But still can't implement what i want. And I want simple behaviour "Redirect on MISS/PASS".
I want to use VC for deploying quick "cdn" servers for our mp4-video-servers (used for HTML5 players), without need to store all files on this quick (ssd, upto 2x480GB space, full database about 6TB).

Currently we have 6 servers with SATA HDDs and hitting iowait like a trucks :) 

Examples:
- Request -> Varnish -> HIT: serve it using Varnish.
- Request -> Varnish -> MISS: start caching data from backend, and instantly reply to client: `Location: http://backend/$req.url"
- Request -> Varnish -> UPDATE: see `-> MISS` behaviour.

From my perspective, i should do this "detach & reply redirect" somewhere in `vcl_miss` OR `vcl_backend_fetch`, because if i understood correctly https://www.varnish-cache.org/docs/4.1/reference/states.html, i need vcl_backend_response to keep run in background (as additional thread) while doing return(synth(...)) to redirect user.

Similiar thing is "hitting stale content while object is updating".
But in my case "replying redirect while object is updating".

Also, i pray to implement this without writing additional scripts, why? I could do external php/ruby checker/cache-pusher with nginx & etc. But scared by performance downgrade :(


More information about the varnish-misc mailing list