Thanks for your quick reply. I tried your config and varnish started with no error but if I send http request in this case, varnish will have empty response. And if I comment off the vcl_deliver it responds as normal. Can you help me a little bit more? Thanks again.
pahud On Mon, Jul 5, 2010 at 10:11 PM, Kristian Lyngstøl < [email protected]> wrote: > On Mon, Jul 5, 2010 at 3:17 PM, Pahud <[email protected]> wrote: > > vcl_deliver(). So I tried this configuration > > sub vcl_deliver { > > if (req.http.Cache-Control ~ "just-cache") { > > error 200 "Cached"; > > return (pass); > > return (pass); doesn't work from vcl_deliver, nor is it needed after > an error-statement. > > > } > > return (deliver); > > } > > But no good luck. I guess vcl_deliver just can't get the value of > > req.http.Cache-Control. > > Is it still possible to achieve this just with VCL? > > Hmm. What you could do is: > > In vcl_fetch: if (req.http.Cache-Control ~ "just-cache") { set > obj.http.X-Cache-Only = "true"; } > In vcl_deliver: > > if (resp.http.X-Cache-Only == "true") { > if (obj.hits == 0) { > error 795 "Cached"; > } else { > remove resp.http.X-Cache-Only; > } > } > > I used the error code 795 to differentiate from 200, so you can catch > it in vcl_error and strip most of the content of the error message if > you want to. You may use whatever error code you want, of course. > > (I haven't tested this, but I don't see why it shouldn't work, except > perhaps syntax typos). > > - Kristian >
_______________________________________________ varnish-misc mailing list [email protected] http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
