Dynamic Cache for Aelia Currency Switcher


im planning on using Aelia Currency Switcher, based on their article.

i have put the nginx code in my conf folder.
but i still cant get it to work.

this is the code i added to conf/nginx/aelia.conf

# Add Aelia cookies to the cache key. This will create multiple copies of each
# cached page (one for each combination of currency, country and province/state)
proxy_cache_key "$scheme$request_method$host$request_uri $cookie_aelia_cs_selected_currency$cookie_aelia_customer_country$cookie_aelia_customer_state$cookie_aelia_billing_country";

# This is an example configuration file, and the settings apply to the entire server.
# You should probably adapt these settings to apply to a specific location, instead,
# so that they only affect your specific ecommerce site.
# If you are not familiar with Nginx configuration, we recommend to contact your
# developer, or hosting provider, who should be able to adjust the settings for you.
set $no_cache 0;
  # If none of the Aelia cookies are set, disable caching. This will ensure that
  # the page is loaded dynamically, and that cookies are set at the next load
  if ($cookie_aelia_cs_selected_currency$cookie_aelia_customer_country$cookie_aelia_customer_state$cookie_aelia_tax_exempt ~* "") {
    set $no_cache 1;
  # Don't pull from cache based on $no_cache
  fastcgi_cache_bypass $no_cache;
  # Don't save to cache based on $no_cache
  fastcgi_no_cache $no_cache;

can anyone guide me on how to do dynamic caching on EE? im using EE+wpredis.


Cache handling is done by an include file (common/redis-php7.conf) so you’ll need to comment out that include in your site config, and create a custom version of it with adapted rules based on what you have from Aelia.


you just have to edit the file /etc/nginx/common/redis.conf (if you use php5.6) or /etc/nginx/common/redis-php7.conf (for php7.0) and to add the following condition:

if ($http_cookie ~* "aelia_cs_selected_currency|aelia_customer_country|aelia_customer_state|aelia_billing_country") {
  set $skip_cache 1;

Just after the block :

if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|[a-z0-9]+_items_in_cart") {
  set $skip_cache 1;

hi @virtubox

after i added the code you gave above, while running gtmetrix, i get this message: Your page generation time is slow

and also my TTFB added 1.5s

i also tried to contact you on your website, but i didnt receive any reply from your side.

is there any way to contact you?


@virtubox, i tried your code it didnt work.

i tried using incognito on my mobile set to UK, and desktop to USA.

when i first view Product A on mobile it shows as in GBP, but when i use my desktop to navigate to the same Product A, it shows GBP as well. not in USD.

can you help?


I’m not sure it will work properly with redis cache.
With fastcgi_cache, it should be easier as you can directly include your variable to the fastcgi_keys directive.