Passing variable data to ESI requests

Rangel, Raul Raul.Rangel at disney.com
Thu Nov 8 16:38:47 CET 2012


Guilhaume,
There are a few tricks you can use to do this. First of all you can extract the cookie that you are interested in and place it in a header.

vcl_recv {
            set req.http.X-Cookie-One = regsub(req.http.Cookie,"^.*?mycookie=([^;]*);*.*$" , "\1");
            unset req.http.Cookie;
}

Then when varnish does the request to the parent page you can completely ignore the X-Cookie-One header. As for the subsequent ESI requests they too should also have the X-Cookie-One header attached to them. In your back end you should be able to read the header and in the response include a Very: X-Cookie-One. This way you get per user caching on the ESI.

Raul

From: varnish-dev-bounces at varnish-cache.org [mailto:varnish-dev-bounces at varnish-cache.org] On Behalf Of Guilhaume Bordiau
Sent: Thursday, November 08, 2012 3:42 AM
To: varnish-dev at varnish-cache.org
Subject: Passing variable data to ESI requests

Hello,

We're using Varnish since a few weeks but are facing the issue of using dynamic content inside cached pages.
We tried ESI for that but it appears that there's no way to pass some (or all) of the original request elements (headers, cookies) to the ESI request made toward our server.

We implemented hacks through cookies read from javascript, triggering ajax requests, but we're facing maintainability issues around browsers refusing cookies (our app run in an iframe and domains are different from the top frame).

So we're starting to think of developing the missing part of code in Varnish that could make it do what we need:
Allow to pass the original request headers and cookies to the ESI URI contained in a cached page.

So my questions are:
- Can you confirm that's it's currently not possible?
- What would be the amount of work to achieve this?
- Any tips to help me getting started with this?

Much thanks in advance to all.

Guilhaume Bordiau.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20121108/581b0e81/attachment.html>


More information about the varnish-dev mailing list