On May 12, 2010 1:41pm, Laurence Rowe <l@lrowe.co.uk> wrote:<br />> On 12 May 2010 08:40, Rob Brown dtownrobbrown@gmail.com> wrote:<br />> <br />> >> If we are talking about stuff in the body of the object, the anwer is<br />> <br />> >> no.<br />> <br />> ><br />> <br />> ><br />> <br />> > yes, unfortunately that is what I am looking for. I am trying to see if<br />> <br />> > varnish can "replicate" the functionality of a commercial cache appliance<br />> <br />> > from a "well-known" vendor.<br />> <br />> ><br />> <br />> >><br />> <br />> >> You could always use ESI for it, but apart from that, there's currently<br />> <br />> >> no way to manipulate the content of a page.<br />> <br />> ><br />> <br />> > ESI would probably work and be much easier, but reading the wiki<br />> <br />> > (http://varnish-cache.org/wiki/ESIfeatures) it seems like Varnish doesn't<br />> <br />> > yet support the "Content substitution based on variables" functionality.<br />> <br />> > I am not well versed in ESI, but I think would be looking to do something<br />> <br />> > like this:<br />> <br />> > <br />> <br />> >  <br />> > href="http://www.example.com/getpage?sessionKey=$(QUERY_STRING{'sessionKey'})"/>get<br />> <br />> > page<br />> <br />> > <br />> <br />> > In the wiki, it says "For now we have deemed this feature uninteresting, but<br />> <br />> > adding it is just a matter of programming." What are the chances of getting<br />> <br />> > support for variables in a future release?<br />> <br />> <br />> <br />> It might be possible to make this work with just ESI includes.<br />> <br />> Assuming that the ESI subrequests reuse the same req object as the<br />> <br />> parent request (I'm not sure about this point), all you need do is<br />> <br />> generate the key as a synthetic response in vcl_error. Something like:<br />> <br />> <br />> <br />> sub vcl_recv {<br />> <br />> if (req.url == "/_esi/sessionKey") {<br />> <br />> error 701;<br />> <br />> } else {<br />> <br />> set req.http.X-Session-Key = # regexp to extract session key from url<br />> <br />> }<br />> <br />> }<br />> <br />> sub vcl_error {<br />> <br />> if (obj.status == 701) {<br />> <br />> synthetic {<br />> <br />> "http://www.example.com/getpage?sessionKey="<br />> <br />> req.http.X-Session-Key "%34>get page"<br />> <br />> };<br />> <br />> }<br />> <br />> }<br />> <br />> <br />> <br />> And use in your page:<br />> <esi:include src="/_esi/sessionKey"/><br />><br />> Laurence<br />> <br /><br />That's pretty cool... Will have to try it!