FOX - Currency Switcher for WooCommerce

Why a currency switcher and a page cache fight each other

Almost every support ticket that starts with "prices show in the wrong currency" ends in the same place: a page cache. It is worth understanding why the two fight each other, because the fix depends on which of them is winning.

What a page cache actually does

A page cache stores the finished HTML of a page and serves that same HTML to everyone. That is the whole point — the server stops rendering and starts handing out a file. It is also exactly the problem. The price on a product page is not a fixed piece of text: it depends on which currency this particular visitor selected. Cache the page while a visitor is browsing in USD, and the next visitor gets USD too, whatever they chose.

The two ways out

There are only two honest approaches, and FOX supports both.

Exclude the pages from the cache. Prices are always correct, and you lose the speed the cache was bought for. This is the right choice for the cart, the checkout and the account pages, which should never be cached anyway.

Cache the page and fix the prices in the browser. FOX ships the cached page as it is, then redraws the price nodes on load in whichever currency the visitor selected. This is what the Cache option in the plugin settings turns on. The page stays fast, and there is a brief moment before the redraw lands — which is what the preloader over the price is for.

Where it goes wrong

The second approach needs the plugin to know the visitor's currency, and that is where caching plugins and CDNs interfere.

If the plugin stores the currency in a cookie, the very first request from a new visitor sets that cookie. Aggressive caches — Cloudflare APO is the strict example — treat any response carrying a Set-Cookie header as personalised and refuse to cache it. The result is a site where the cache appears to be enabled and never actually caches anything.

Since v.2.5.0 FOX avoids this. With Storage set to Transient and the cache option enabled, the plugin keeps a random key in the browser's localStorage instead of setting a cookie, so the HTML that leaves the server is identical for everyone and the cache can do its job. Every other storage combination behaves as it did before.

The checklist

  • Cart, checkout and account pages excluded from the cache — always.
  • The plugin's Cache option enabled if the shop pages are cached.
  • Storage set to Transient if a CDN sits in front of the site.
  • The plugin's JavaScript not deferred or combined by an optimiser — the redraw runs on load, and an optimiser that delays it turns the preloader into a permanent spinner.

If prices are still wrong after all four, the cache is not the cause. Open a support topic with the page URL and the caching setup, and we will look at it.