fastcgi_cache with geoip

Hi, recently we are using the geoip module in our wordpress templates to send different contents to users based on their country of origin. But with the fastcgi cache, people from different countries will still see the same content till the cache expires.

Is there a way to make a different cache copy for different countries?


Sorry for late reply.

I assume based on IP, you are setting cookie or some env variable. If its cookie and its cookie name is country, you can alter:

fastcgi_cache_key "$scheme$request_method$host$request_uri";  

To include $cookie_county

fastcgi_cache_key "$scheme$request_method$host$request_uri$cookie_county";  

Please note that you will also need to modify location /purge accordingly.

This way for every page, county specific cached version will be stored.