On 19.10.2011 17:29, Maikel Brouwer - Songteksten.nl wrote:

> if ($country == 'be') {
>   //display stuff
> } else {
>   //display other stuff)
> }
> 
> The problem is that when someone from 'be' visits the page when it's not
> yet cached the code in the 'be' block will be cached. When someone from
> 'nl' visits the page it will see the 'be' block.

I'd probably resolve the GeoIP country in VCL and set an HTTP header:
| set req.http.X-Country-Code = geoip.client_country_code();

The webserver then would have to add a "Vary: X-Country-Code" header to
country-specific pages. E.g. in apache:
| Header merge Vary X-Country-Code

varnish would cache one copy of each object for every country code, so
you might want to reduce the additional header to "be-or-not-be".

A better option could be to use ESI and cache the HTML code for pages
and ads separately. I haven't tested ESI with varnish yet, so I cannot
give an example here.


Hauke.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to