Dynamically generating tracking images
Ruslan Sivak
russ at vshift.com
Wed Oct 27 19:12:47 CEST 2010
So I can't get access to the original query string? What about request
cookies?
Russ
On Wed, Oct 27, 2010 at 1:05 PM, Josh <josh at schulzone.org> wrote:
> You have to put the query string parameters into the esi path:
>
> <esi:include src="/esi/
> tracker.pl?url=ENTER+PAGE+URL+HERE&title=ENTER+PAGE+TITLE+HERE"/>
>
> I'm handling some tracking the exact same way, and it works fine. The
> esi request is a separate hit to the backend and doesn't have any of
> the context from the request that caused it.
>
> josh
>
> On Wed, Oct 27, 2010 at 9:51 AM, Ruslan Sivak <russ at vshift.com> wrote:
> > We are building a site which needs to be cached, but we need to have a
> > tracking image that gets output for every page. This image should
> contain
> > certain (lets say all) parameters of the query string.
> >
> > I'm thinking of implementing this using ESI. I currently have the
> > following:
> >
> > test.php
> > <esi:include src="/esi/tracker.pl"/>
> >
> > /esi/tracker.pl
> > #!/usr/bin/perl
> > use CGI::Cookie ();
> > use Apache2::RequestRec ();
> > use APR::Table ();
> > my $cookie = CGI::Cookie->new(-name => 'mod_perl',
> > -value => 'awesome');
> > print "Set-Cookie: $cookie\n";
> > print "Content-type: text/html\n\n";
> > print <<ENDHTML;
> > $ENV{'QUERY_STRING'}
> > <div>
> > <img
> > src="
> http://sometrackingsite/id/12345.gif?url=ENTER+PAGE+URL+HERE&title=ENTER+PAGE+TITLE+HERE
> "
> > alt="" height="1" width="1" />
> > </div>
> > ENDHTML
> >
> > default.vcl
> > ...
> > sub vcl_fetch {
> > set beresp.ttl=5d;
> > if (req.url ~"test.php") {
> > esi; /* Do ESI processing */
> > set beresp.ttl = 24 h;
> > } elseif (req.url == "/esi/tracker.pl") {
> > set beresp.ttl = 1m;
> > }
> > if (beresp.http.set-cookie) {
> > set beresp.http.set-cookie = ";" beresp.http.set-cookie;
> > set beresp.http.set-cookie = regsuball(beresp.http.set-cookie, "; +",
> > ";");
> > set beresp.http.set-cookie = regsuball(beresp.http.set-cookie,
> > ";(MY_COOKIE)=", "; \1=");
> > set beresp.http.set-cookie = regsuball(beresp.http.set-cookie, ";[^
> > ][^;]*", "");
> > set beresp.http.set-cookie = regsuball(beresp.http.set-cookie, "^[;
> > ]+|[; ]+$", "");
> >
> > if (beresp.http.set-cookie == "") {
> > remove beresp.http.set-cookie;
> > }
> > return (deliver);
> > }
> > }
> > ...
> >
> > Am I going about this the right way? Perl doesn't seem to see the query
> > string or be able to set any cookies.
> >
> > Any help would be appreciated.
> >
> > Russ
> >
> > _______________________________________________
> > varnish-misc mailing list
> > varnish-misc at varnish-cache.org
> > http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
> >
>
>
>
> --
> josh
> @schulz
> http://schulzone.org
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20101027/83a9e1ad/attachment-0003.html>
More information about the varnish-misc
mailing list