Nginx Opcache (fastcgi_cache_key) and GeoIP

258 views Asked by At

I've searched Google / this forum for this but can't find anything relevant so apologies in advance if this has been covered elsewhere.

I've enabled Opcache on my server and have GeoIP enabled.

The default fastcgi_cache_key directive is:

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

How can this be modified to include the user country (from GeoIP) so that each country has a separate cache entry for each page?

As far as I'm aware, the GeoIP headers are set in the server {} block which is loaded after /etc/nginx/nginx.conf (where the fastcgi_cache_key) is set.

Additionally, I've tried setting the fastcgi_cache_key in the individual site conf file but this only works when only 1 site is enabled.

Have I missed a really simple step here?

Many thanks,

James

0

There are 0 answers