Not caching a block

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
AverilL's picture

I am currently working on a site that is recieving over 200K visitors per month. We are using some refererer tracking code to replace the site logo depending on where the client has arrived from. The logo is contained in a block. This is implemented on almost every page.

What would the best approach to setting up some kind of cache under these circumstances?

Currently we are using some client side JS to do the logo swapping but it is proving problematic/unreliable on some browsers. IE8 in particular but we have to support IE8.

Is it possible to use some sort of hole punching in caches?

I'm a bit out of depth here ans would appreciate some feedback

Comments

Yes, JS sounds like the best

dalin's picture

Yes, JS sounds like the best route. I can't think of why that wouldn't work in IE8.

And assuming that you're using Varnish or the like you'll want to remove the GET parameters before sending the request to the back-end. Something like this in vcl_recv():

# Strip various GET params that are only used by JavaScript and should not
# cause multiple versions to be stored in the Varnish cache.
set req.url = regsuball(req.url, "([\?|&])foo=[^&\s]&?", "\1");
set req.url = regsuball(req.url, "([\?|&])bar=[^&\s]
&?", "\1");
# Remove any trailing & or ?
set req.url = regsuball(req.url, "[\?|&]+$", "");

--


Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his