Skip to content

Commit c257d14

Browse files
committed
chore: update demo README to reflect KV-optional architecture
Remove KV namespace as a required setup step since the implementation now uses Cloudflare's native cf.cacheTtl for config caching and deterministic MurmurHash bucketing for visitor assignment.
1 parent 2f0e183 commit c257d14

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

demo/cloudflare-workers/README.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,16 @@ A complete example of running Convert A/B tests at the Cloudflare edge with zero
1818
yarn install
1919
```
2020

21-
### 2. Create a KV Namespace
22-
23-
```bash
24-
wrangler kv namespace create CONVERT_KV
25-
```
26-
27-
Copy the output `id` into `wrangler.toml`.
28-
29-
### 3. Configure
21+
### 2. Configure
3022

3123
Edit `wrangler.toml`:
32-
- Set your KV namespace ID
33-
- Set your Convert SDK key (`CONVERT_SDK_KEY`)
24+
- Set your Convert SDK key (`CONVERT_SDK_KEY`) in the format `ACCOUNT_ID/PROJECT_ID`
3425

35-
### 4. Update Experiment Keys
26+
### 3. Update Experiment Keys
3627

3728
In `src/index.ts`, replace `'your-experience-key'` with your actual experience key from the Convert dashboard.
3829

39-
### 5. Run
30+
### 4. Run
4031

4132
```bash
4233
# Local development
@@ -53,19 +44,23 @@ yarn tail
5344

5445
```
5546
Visitor → Cloudflare Edge → Worker
56-
├── Read config from KV (cached, ~1ms)
57-
├── Read visitor data from KV (~1ms)
58-
├── SDK: bucket visitor into variation
47+
├── Fetch config (edge-cached via cf.cacheTtl, ~1-5ms)
48+
├── SDK: bucket visitor into variation (MurmurHash)
5949
├── Fetch origin page
6050
├── HTMLRewriter: modify HTML per variation
6151
├── Set visitor cookie
6252
└── Respond (total edge overhead: ~5-8ms)
6353
6454
└── Background (waitUntil):
65-
├── Save bucketing to KV
6655
└── Send tracking event to Convert
6756
```
6857

58+
No KV namespace is required. Config is cached using Cloudflare's native `cf.cacheTtl` fetch option (free, all plans). Visitor bucketing is deterministic — the same visitor ID always gets the same variation via a cookie.
59+
60+
## Optional: KV-Backed Persistence
61+
62+
If you need to preserve bucketing across experience config changes or store custom visitor attributes, you can optionally add KV support. See the commented section at the bottom of `src/index.ts` for setup instructions.
63+
6964
## Documentation
7065

7166
Full guide: [Cloudflare Workers Edge Experimentation](https://github.com/convertcom/javascript-sdk/wiki/CloudflareWorkers)

0 commit comments

Comments
 (0)