You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: demo/cloudflare-workers/README.md
+12-17Lines changed: 12 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,25 +18,16 @@ A complete example of running Convert A/B tests at the Cloudflare edge with zero
18
18
yarn install
19
19
```
20
20
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
30
22
31
23
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`
34
25
35
-
### 4. Update Experiment Keys
26
+
### 3. Update Experiment Keys
36
27
37
28
In `src/index.ts`, replace `'your-experience-key'` with your actual experience key from the Convert dashboard.
38
29
39
-
### 5. Run
30
+
### 4. Run
40
31
41
32
```bash
42
33
# Local development
@@ -53,19 +44,23 @@ yarn tail
53
44
54
45
```
55
46
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)
59
49
├── Fetch origin page
60
50
├── HTMLRewriter: modify HTML per variation
61
51
├── Set visitor cookie
62
52
└── Respond (total edge overhead: ~5-8ms)
63
53
64
54
└── Background (waitUntil):
65
-
├── Save bucketing to KV
66
55
└── Send tracking event to Convert
67
56
```
68
57
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
+
69
64
## Documentation
70
65
71
66
Full guide: [Cloudflare Workers Edge Experimentation](https://github.com/convertcom/javascript-sdk/wiki/CloudflareWorkers)
0 commit comments