Multi-currency Websites


I’ve got an e-website which serves a global user-base in multiple currencies. The documentation for Cloudflare seems to suggest that the CDN cache is based only on the URL, this works where different markets have separate domains — but some markets use the same domain serving content in multiple currencies. Can the cache be configured to account for an additional header or cookie which specifies the currency as a shard?

1 Like

You could probably add ?currency=aa since query strings are part of the cache key.

Also note that you should only worry about the CF cache if you dynamically tell the user what currency they use via js or css files (files served from cache) or if you use a ‘cache everything’ page rule. If you tell the client what currency to use based off of its IP address, or via the actual HTML page, CF shouldn’t be caching the currency anyways.


I want CF to cache the page HTML as some pages are large and take a long time to transfer to some users (particularly in Australia). The currency is defaulted but can be changed by the user and is persisted via a cookie. Unfortunately I’m unable to add the currency to the URL so would need to include a header or cookie as part of the cache key.

The only way to manipulate the cache with a cookie is “bypass cache on cookie” but that just disables the cache if that cookie is present. Unfortunately I don’t think this is possible.

On Cloudflare’s Enterprise Plan you can create a custom cache key based on cookie in page rules or Workers.

Couldn’t you do this with a worker, read the cookie and add the currency to the request on the fly?

I am afraid I dont get the connection between currency and cache. Just because some goes e.g. via a US datacentre does not necessarily mean that person will use USD as currency.

Unless there is something I am missing I would say the approach is wrong in this case. If you really want to outsource the currency selection to Cloudflare I’d say the worker approach mentioned by @thedaveCA might be the most feasible option.

This topic was automatically closed after 30 days. New replies are no longer allowed.