-
Notifications
You must be signed in to change notification settings - Fork 30
fix(vtex): gate vtex_segment cookie on isCacheableSegment #1642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
a3318ba
7f31a43
3a0259d
fc94805
4842ac6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -260,9 +260,11 @@ export const setSegmentBag = ( | |||||||||||||||||||
| }); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Only set vtex_segment when the channel is non-default so that default-SC | ||||||||||||||||||||
| // responses remain cacheable by the CDN without a Set-Cookie header. | ||||||||||||||||||||
| if (vtex_segment !== token && !isAnonymous(ctx)) { | ||||||||||||||||||||
| // Only set vtex_segment on non-cacheable responses so cacheable ones (incl. | ||||||||||||||||||||
| // UTM-only and non-default sales channel) stay Set-Cookie-free and CDN- | ||||||||||||||||||||
| // cacheable. Mirrors the middleware's cacheability check (isCacheableSegment) | ||||||||||||||||||||
| // so the cookie gate and the Cache-Control decision never disagree. | ||||||||||||||||||||
| if (vtex_segment !== token && !isCacheableSegment(ctx)) { | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: This gate removes only Prompt for AI agentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Logged-in UTM requests now skip Prompt for AI agents
Suggested change
|
||||||||||||||||||||
| setCookie(ctx.response.headers, { | ||||||||||||||||||||
| value: token, | ||||||||||||||||||||
| name: SEGMENT_COOKIE_NAME, | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: UTM-only requests now become publicly cacheable here, but
simulation.tsstill treats any UTM as non-anonymous and sends it asmarketingData; a VTEX promotion keyed by that UTM can therefore produce a campaign price in a response shared with users without the UTM. Requests whose marketing data can affect pricing need to remain out of the public page cache, or those fields need to be excluded from simulation for cacheable requests.Prompt for AI agents