Commit f7fd981
feat: enable CDN cache for all sales channels (#1562)
* feat: enable CDN cache for all sales channels
* feat: enable CDN cache for all sales channels
- Remove isDefautSalesChannel restriction from isCacheableSegment so
non-default channels are cacheable (CDN varies by vtex_segment/VTEXSC)
- Always persist VTEXSC cookie for ?sc=X requests regardless of
cacheability, ensuring sales channel continuity across navigation
- Remove unused PAGE_CACHE_ALLOWED_KEY import from vtex middleware
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* fix: guard non-default channels against caching when channelPrivacy is unknown
Non-default sales channels are only cacheable when channelPrivacy is explicitly
"public". If channelPrivacy is null/undefined (e.g. cold request), skip CDN
cache to avoid serving a private channel response on first hit.
* fix: skip Set-Cookie on cacheable responses to allow CDN caching
Cloudflare does not cache responses with Set-Cookie headers. Guard both
VTEXSC and vtex_segment cookies inside the !isCacheableSegment block so
cacheable responses stay cookie-free and the CDN can cache them.
Navigation continuity is preserved: the first cold request for a non-default
channel is always non-cacheable (channelPrivacy unknown), so cookies are
set there and carried by the browser on subsequent requests.
* feat: enable CDN cache for all sales channels via cookie vary
Remove channel restriction from isCacheableSegment — all non-private
channels are now cacheable. Always set vtex_segment and VTEXSC on every
response so the CDN (Cloudflare) can vary its cache key by them and serve
the correct bucket per sales channel.
Requires deco-cx/deco#XXXX (allowlist vtex_segment/VTEXSC in middleware).
* fix: remove UTM checks from isCacheableSegment
* fix: replace removed @deco/deco RequestInit import with local DecoRequestInit
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>1 parent 0b95d39 commit f7fd981
3 files changed
Lines changed: 29 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
85 | | - | |
| 84 | + | |
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
| |||
241 | 240 | | |
242 | 241 | | |
243 | 242 | | |
244 | | - | |
| 243 | + | |
245 | 244 | | |
246 | 245 | | |
247 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | 48 | | |
54 | 49 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 64 | | |
71 | 65 | | |
72 | 66 | | |
73 | 67 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
82 | 71 | | |
83 | 72 | | |
84 | 73 | | |
| |||
259 | 248 | | |
260 | 249 | | |
261 | 250 | | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
275 | 262 | | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
285 | 273 | | |
286 | 274 | | |
0 commit comments