Contents
On this page
Page caching - Plugixa Multi Currency for WooCommerce
A page cache saves a copy of each page and serves it to the next visitors. Without care, a shopper in euros could be served a page someone else saw in dollars. This page explains how the plugin avoids that, and what it needs from your cache.
How it works: one copy per currency
The free plugin renders each page in the shopper’s currency on the server. Behind a page cache,
that means the cache must keep one copy of each page per currency, chosen by the currency cookie
plugixa_mc_currency. This is called varying on a cookie.
A visitor who has not picked a currency has no cookie and gets the store-currency copy. A shopper who picks euros gets the euro copy from then on.
Set up for you
With these three cache plugins, the plugin adds its cookie to the cache’s own settings by itself. There is nothing to configure.
| Cache plugin | What the plugin sets up |
|---|---|
| WP Rocket | The currency cookie as a dynamic cookie, so each currency gets its own cached copy. WP Rocket’s .htaccess rewrite rules are turned off, because they would serve the cached file before WordPress can read the cookie. |
| LiteSpeed Cache | The currency cookie in LiteSpeed’s vary cookies, both in the response and in its rewrite rules. |
| WP Super Cache | The currency cookie in WP Super Cache’s cookie list. In expert mode its .htaccess rules are rewritten to include it. |
The setup runs the first time an administrator opens wp-admin after one of these plugins is installed, activated or removed, and the plugin empties the page cache once so no page saved before the change is served. The same happens when the cache setup changes.
Search engines
Crawlers always get your store currency: the plugin never converts a page for a search engine
bot. Each address has one price in search results, and the switch links are marked nofollow.
With Pro, each currency can have its own indexable address PRO. See
Currency URLs.
Cart and checkout
WooCommerce and the cache plugins above never cache the cart, the checkout and My Account. Those pages are always rendered fresh, in the shopper’s currency.
The mini-cart is refreshed by WooCommerce in the browser. The plugin adds the currency to the cart hash, so a mini-cart saved in the browser in one currency is not shown in another.
Other caches and CDNs
Other page caches cannot be set up to vary on a cookie automatically. The plugin empties the cache of W3 Total Cache, WP Fastest Cache, Breeze and WP-Optimize when the cache setup changes, but it cannot make them keep one copy per currency. The same goes for a CDN or a hosting cache, such as Cloudflare’s full-page cache or Varnish.
With one of these, you have two choices:
- Free: set the cache to vary on the
plugixa_mc_currencycookie, if it can, or to skip the cache for visitors who have that cookie. Check your cache’s documentation for “vary on cookie” or “bypass cache on cookie”. - Pro: switch on cache-first mode PRO. Pages are cached once, in your store currency, for everybody, and the prices on them are switched to the shopper’s currency in the browser. Any cache or CDN keeps its full hit rate, and the Tools page checks your setup live. See Cache-first mode.
Check your setup
- Open a product page in a private browser window. It shows your store currency.
- Pick another currency in the switcher. The prices change.
- Reload the page, then open another product. Prices stay in the currency you picked.
- Open the same product in a second private window, without picking a currency. It shows your store currency.
If step 3 or 4 shows the wrong currency, your cache is serving one copy to everybody: see Troubleshooting.
For developers
plugixa_multi_currency_purge_page_cache(action) runs after the plugin empties the caches it knows. Hook it to empty a CDN or a cache it does not know.plugixa_multi_currency_cache_plugins(filter) changes the list of detected cache plugins.
Quick Links
Share