news icon

WooCommerce Currency Switcher and cache – Making them work together

This article continues in WooCommerce and cache – Part 2: new Cache Handler plugin

One of the most common questions we receive from our customers is how to make a highly dynamic, multi-currency, multi-pricing, geolocation-enabled sites work properly with caching enabled. This is not always an easy task, because caching systems are designed with the assumption that the content served by a site doesn’t change depending on the visitor. Such assumption holds true in many cases, as a large number of sites does indeed serve the same content to whoever views a page. In such case, the standard behaviour of caching systems, which is storing one copy of each page in the cache, is acceptable.

As soon as multi-currency features are added, the same behaviour proves itself too limited, because the assumption behind it becomes incorrect. A multi-currency shop serves different content to different visitors, depending on the currency and other criteria (applicable taxes, regional pricing, etc). Quite simply, having one cached copy of each page just doesn’t cut it anymore.

Until recently, the only way to prevent caching from interfering with the multi-currency features was to disable it on catalogue pages. Doing so ensures that the shop can produce content dynamically, showing the correct information to each visitor. In some cases, when the caching system in use is too rigid, this is still the only solution.

How WooCommerce handles the issue

WooCommerce itself has to deal with caching since its team introduced geolocation features in it. The WC team added a workaround to “trick” caching systems into letting WooCommerce serve the correct data. Such workaround works by reloading the shop pages in a way that cache is ignored. This ensures that the page shows the correct content but, in our opinion, it’s not an ideal approach. We certainly appreciate the effort put into it, and the fact that there isn’t much more that a plugin can do to correct the behaviour of the caching system. However, we decided to find an alternative, more robust solution.

Our solution

Our opinion is that caching systems should adapt to your site, not the other way round. Issues caused by caching should be solved by fixing the caching. With this in mind, instead of implementing a workaround, we tackled the issue at its root, and wrote an algorithm for dynamic caching that takes into account the needs of a multi-currency website.

The algorithm is straightforward, and solves the issue by addressing its cause: instead of one copy of each page, it allows caching systems and plugins to store multiple copies of each page (such as one for each currency). With that in place, visitors from all over the world will see the content that applies to them, with the correct currency and taxes applied. If visitors choose another currency, or country, then our plugins track their choice, and the dynamic caching logic uses it to serve them the correct content.

Our solution grants top performance, with maximum flexibility.

Supported Systems

Dynamic caching is a great solution for highly dynamic, multi-currency sites. However, it can only work if the caching system in use supports it. As of October 2015, the following plugins and systems support, or are planning to support, dynamic caching.

WordPress Plugins

Caching Systems

For caching plugins and systems that do not support dynamic caching, disabling cache on catalogue pages is still necessary to allow the multi-currency features to work correctly.

How to add dynamic caching to your site

Adding it to your site can be as simple as copying one file, or changing one configuration file. In order to allow you to get started quickly, we wrote an implementation of dynamic caching for the following systems:

  • ZenCache/Comet Cache
  • Nginx

You can find detailed instructions to install and configure each of our solutions, as well as indications for other systems, in our knowledge base: How to add dynamic caching to your site.

We also discussed the implementation extensively with the WP Rocket Team, and provided them with code examples for integration. They confirmed that they are going to add support for dynamic caching and multi-currency sites directly in their plugin.

With dynamic caching and our Currency Switcher, your WooCommerce site will be faster and more flexible than ever!

What about systems that don’t support dynamic caching?

Plugins and caching systems that don’t support dynamic caching still have to be disabled on the catalogue, at least until they are updated. We believe that caching systems should be flexible, and support for dynamic caching is not particularly difficult to implement.

If you are using a plugin, or a caching system that doesn’t support dynamic caching, we recommend thar you get in touch with its authors and express your interest in such feature. You can also suggest them to contact us directly, if they have any questions. We will be happy to provide them with all the information they need to improve their solution.

Questions? Feedback?

We hope that you enjoyed this great news. A faster e-commerce means more customers, and that is always good! If you have any questions about our solutions, or if you would like to send us your feedback, please feel free to contact us. We will get back to you in no time.

Thank for your time and continued support.

The Aelia Team

11 replies
  1. James says:

    Very nice explanation here and very appropriate it is tackled at the caching level. I am using hyper-cache and I believe I will need to disable for the catalogue for the time being. Would this mean every page after the default permalink of /shop

    • diego says:

      Hi James,
      That’s correct. If HyperCache does not support dynamic caching, then you will have to disable caching on URLs that start with /shop and /product. Please note that these are the default URLs, and that each shop may use a different keyword (for example /catalogue).

      I would also suggest to contact the author of the HyperCache plugin and register your interest in having a dynamic caching feature. We will be happy to provide the developer(s) with more details, like we did with WP Rocket, to get such feature included as soon as possible.

      • James says:

        Thanks Diego, I will indeed get in touch with Hyper cache and thanks for the help here. I appreciate the quick response.

  2. Scott Adrian says:

    This is a much needed development indeed. Only problem is I have tried to implement it using the steps for WP Super Cache and my product pages are still not dynamicly cached. They’re still keep the original currency chosen and when you try to switch the currency and refresh the page it reverts to the original currency of the cached page instance.

    Any additional developments or steps I need to take in order to get this working properly?

    • diego says:

      Hi Scott,
      Several possible reasons come to my mind for the issue you describe:

      1. Super Cache was not configured correctly. It’s not the easiest plugin to configure (path, plugin, settings, etc), therefore the module we wrote is not being loaded. If you are not familiar with the intricacies of PHP debugging, switching to ZenCache might make your life easier.
      2. There is another caching on top of the Super Cache one, and it’s the one serving the stale content (often, CloudFlare does that). In such case, you would have to disable the additional caching layer
      3. You enabled the “force currency by billing country” option. That option overrides any currency you select and forces the one in use in the country associated with your session (detected or selected manually). If you want customers to select the currency, then you must disable the “force currency” option, as indicated in the settings page.
  3. Scott Adrian says:

    Thanks for the reply. I am currently not running the newest version of the currency switcher. Could that be the issue or is dynamic caching compatible with Version

    • diego says:

      Now that you mention it, that’s the issue (I assumed you were using the latest version of the Currency Switcher). We abandoned sessions in favour of cookies in version, both to support dynamic caching and to prevent the bloating of the options table. Simply download the latest version of the plugin, and everything should work fine. Also, since the link you have will expire in a few days, remember to get in touch to get your renewal discount. 🙂

  4. Phil C says:

    This is awesome! Sadly I don’t have CloudFlare Enterprise, so won’t be able to take advantage of this, but I still think it’s cool 🙂

    • diego says:

      Hi Phil, thanks for your feedback. We are glad that you liked the article. It took a lot of work to reach this solution and, even if you don’t have CloudFlare Enterprise, you can still get excellent results by tuning Nginx or your caching plugin of choice.

  5. veptune says:


    We are currently using Cloudflare, but not the Entreprise plan which is far far too expensive.

    Why this plugin only support “entreprise plan” ? Can we require a quote to make it works for normal cloudflare plan ? Can you make it compatible with MaxCDN ?


    • diego says:

      Thanks for getting in touch. I need to make a small clarification in relation to your question. It’s not that the Currency Switcher only supports the CloudFlare Enterprise plan, it’s that the CloudFlare service only supports the suggested caching configuration with that plan. From a more generic perspective, to have a robust solution it’s necessary that the caching systems are configured to work correctly with the site, not expect each plugin to adapt to the caching systems. In other words, the Currency Switcher and other plugins won’t deal with specific caching systems, as they are not supposed to.

      When the caching systems can’t be configured as needed, you can use a workaround such as our free Cache Handler plugin. Its redirect mode works with CloudFlare (any plan) and it should also work with MaxCDN (although, we haven’t tested that specifically).

      For more information about dynamic caching, please refer to the following article: Aelia – How to add dynamic caching to your site.


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.