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