feat(core): add X-Correlation-ID header, cache guest queries separately#2910
Open
feat(core): add X-Correlation-ID header, cache guest queries separately#2910
Conversation
🦋 Changeset detectedLatest commit: 173377f The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4daa258 to
b4cfed3
Compare
Contributor
Bundle Size ReportComparing against baseline from No bundle size changes detected. |
b4cfed3 to
ac729db
Compare
ac729db to
827eb1e
Compare
9af30f0 to
d9c2fd4
Compare
d9c2fd4 to
40ee9ce
Compare
40ee9ce to
bdb6aec
Compare
Contributor
Unlighthouse Performance Comparison — VercelComparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores. Summary ScoreAggregate score across all categories as reported by Unlighthouse.
Category Scores
Core Web Vitals
|
bdb6aec to
173377f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What/Why?
All GraphQL requests now include an
X-Correlation-IDheader containing a UUID that is stable for the duration of a single page render (viaReact.cache), making it easier to trace and correlate all requests made during a single render in server logs.Guest (unauthenticated) queries are now cached using
unstable_cachewith the configured revalidation interval, while authenticated requests continue to usecache: 'no-store'. This separates cacheable public data from session-specific data, improving performance for unauthenticated visitors. TheX-Forwarded-ForandTrue-Client-IPheaders are only forwarded on uncached (no-store) requests since they are unavailable insideunstable_cache.Testing
Locally + E2E
Migration
Step 1: Add the correlation ID helper
Create
core/client/correlation-id.ts:Step 2: Update
core/client/index.tsUpdate the
beforeRequesthook to add theX-Correlation-IDheader to all requests and to only forwardX-Forwarded-For/True-Client-IPon uncached requests:Step 3: Wrap guest queries with
unstable_cacheFor each page data file, wrap the guest (unauthenticated) fetch in
unstable_cacheand branch on whether acustomerAccessTokenis present. Example pattern:Future path with Next 16
We will eventually migrate to use
cacheComponents, so this migration tounstable_cachewill provide as the foundation of caching request functions in Catalyst going forward. In a future scenario, it will be as simple as replacingunstable_cachefor theuse cachedirective.