Multi country cache problem

Maikel Brouwer - Songteksten.nl mbrouwer at songteksten.nl
Thu Oct 20 23:39:31 CEST 2011


On Wed, 2011-10-19 at 19:39 +0200, Hauke Lampe wrote:
> 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.

Thanks for the advice. 

But, when I'm using the geoip plugin from varnish it gives me the
following error:

(https://www.varnish-cache.org/trac/wiki/GeoipUsingInlineC)

Starting HTTP accelerator: varnishd failed!
Message from C-compiler:
./vcl.giASc5vH.c: In function ‘VGC_function_vcl_hash’:
./vcl.giASc5vH.c:569: warning: implicit declaration of function
‘VRT_l_req_hash’
Message from dlopen:
Compiled VCL program failed to load:
  ./vcl.giASc5vH.so: undefined symbol: VRT_l_req_hash
Running dlopen failed, exit 1

VCL compilation failed

Maybe it is not working anymore in v3? I'm using the example VCL that
was provided and installed Maxmind GeoIP C API without problems.

Thanks,

Maikel





More information about the varnish-misc mailing list