Changing req.hash
Martin Goldman
me at mgoldman.com
Tue Jun 1 14:07:26 CEST 2010
Hi folks,
We're adding a mobile version of our site. We don't want to redirect mobile
users to a different URL, we want to just present the mobile site to
visitors who access our site with a mobile-like useragent. So I got the idea
from this site (http://groups.drupal.org/node/63203) to change req.hash for
mobile requests so that they'll get cached separately using logic like this:
sub vcl_hash {
/* Have a separate object cache for mobile site based on User-Agent */
if (req.http.host == "www.domain.org" && req.http.User-Agent ~
"(iPhone|iPod)") {
set req.hash += "mobile";
}
}
This basically works as expected, but I'm having one issue. We
programmatically purges pages from Varnish when they're updated. Obviously
to do so, we need to know the hash of the page. The hash syntax we've always
used, which works fine for the non-mobile requests, is:
^/this/is/the/uri#mysite.com#$
But I'm not totally clear on how appending "mobile" to the hash changes the
syntax. I remember reading once that custom VCL runs *before* the default
VCL, so I thought the hash would be something like this:
^mobile/this/is/the/uri#mysite.com#$
However, purging that doesn't work. Any ideas?
Apologies if the answer to this is out there somewhere, I just haven't had
any luck finding it.
Thanks and regards,
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20100601/bb61a91b/attachment-0003.html>
More information about the varnish-misc
mailing list