Closed duylddev closed 5 years ago
Your website varies the response using the request IP. That setup doesn't go well with a cache in the proxy. The right way to do this is to map the request IP to a request Header before srcache handles the request, and Vary the response upon that header.
I wrote Actual detected country because the Country detected by geoip might not be the one you actually choose in the application. For example you might map 'FR' and 'ES' to 'EU' in the application, so you have to tell the cache (as done above) to set its store key accordingly.
Thank you for replying, I understand that solution but I don't know how to build store key using response X-ClientCountry header.
Could you give more information?
It's great if you give me an example
From the documentation example (assuming you're using X-Client-Country header)
more_set_headers 'X-Country-Code: $geoip_city_country_code3';
set $fetchKey "$geoip_city_country_code3-$uri?$args";
set $storeKey "$sent_http_x_client_country-$uri?$args";
srcache_fetch GET /memc $fetchKey;
srcache_store PUT /memc $storeKey;
Cool huh ?!?
set $key "example.com_page:https$http_cf_ipcountry$request_method$host$request_uri";
I'm using Cloudflare so that's my config and it's worked =))))
Thank you so much :D
Cool ! If you're using Cloudflare then yes, there is already a http header available, so indeed there is no need to set one up. You might want to close this issue...
Oh, I forgot it too much focus on coding =))
Our Wordpress website has a mutilple currency plugin and here's the thing
With the same url like: https://example.com/products/product-name The plugin basiclly check user Geolocation and return the match currency, but SRCache return the HTML content before the plugin run so US or AU or UK user see the US price That's not true
What should I do now?