Does code belong in vcl_recv & vcl_fetch?

Per Buer perbu at varnish-software.com
Fri May 10 08:45:27 CEST 2013


On Thu, May 9, 2013 at 10:47 PM, John <spam at onlineconcepts.com> wrote:

>
> Do I need to place this code in both the vcl_fetch and vcl_recv? I've
> currently got it in both places, but I do not want to duplicate code
> unless it's required (or a best practice).
>
>
You do two totally different things in recv and fetch. In recv you can
modify the req object, changing the _request_. In fetch you modify beresp,
the backed response. Cookie is a request header, so change it in recv. If
you where to alter Set-Cookie OTOH, you would do so in fetch.

I would recommend to spend some time on the Varnish Book og the tutorial
"Using Varnish". Or, if you are in NYC on the User Group meetup around the
end of May there will also be a training session.
-- 
 <http://www.varnish-software.com/> *Per Buer*
´Varnish Software
Phone: +47 958 39 117 | Skype: per.buer
We Make Websites Fly!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130510/915202c5/attachment.html>


More information about the varnish-misc mailing list