🌏 E-commerce / Retail

Edge Compute — Local Currency at the Edge

Cloudflare reads request.cf.country, city, and PoP on every request — zero latency, zero geo-IP API cost. Show local pricing to each visitor without touching your origin.

The Problem

"Every visitor sees USD prices. Customers in Thailand, Indonesia, and Malaysia do the mental conversion — or just leave. Fixing this on the origin means a geo-IP API, an FX rate API, and backend changes."

The Outcome

0ms

geo lookup time. Cloudflare adds country, city, and PoP to every request for free — no API, no subscription, no origin change.

Live demo below

The problem

Your origin serves USD prices to every visitor — regardless of their country.

""Our local customers see $199 prices. They convert mentally and still wonder if our store is even available in their country. Our bounce rate from local markets is 3× higher than markets where we show local currency.""

Head of E-commerce, Regional Retail Platform

Both sides run simultaneously — real API calls, no mocks

Without Edge Compute
Origin geo-IP lookup

Without Cloudflare Workers

1. Request arrives at origin
2. Origin calls geo-IP API → ~150ms
3. Origin calls FX rate API → ~130ms
4. Response with localised price → ~280ms total
+ geo-IP API subscription + FX rate API + extra origin load
Visitor sees
$199.00
USD — always
Latency
origin + geo-IP + FX
With Edge Compute
request.cf.* — zero origin call
Click "Run Demo" to detect visitor location

The win

0ms
Edge response time
vs ~280ms origin + geo-IP API
🌏
10+
Local currencies
THB/SGD/IDR/MYR/PHP/VND + more
🔧
0
Origin code changes
Worker intercepts and enriches

Productionising this

What changes when you ship this for real

Don't trust country alone

request.cf.country is the resolved viewer location. For pricing decisions, also check cf-ipcountry header consistency and consider a server-side override (user account preference > geo).

FX rate freshness

Hard-coded FX rates drift. Cache live rates from a provider (openexchangerates, frankfurter.app) in KV with 1h TTL. Worker reads cached rate, computes local price.

GDPR / data residency

request.cf.* is provided by Cloudflare without transit through external geo-IP services — but you still must disclose location-based pricing in your privacy policy if you charge differently per market.

A/B test pricing

Bucket users with request.cf.country + cf-ray hash → KV-stored experiment cohort. Workers run the bucketing at the edge, not on the origin.

Country override for tests

Honour a ?force-country=PT query param (gated by an admin-token cookie) so QA can validate pricing flows for any market without VPN.