fix(objectql,rest): single-item meta reads must revalidate (no max-age=3600)#2264
Merged
Conversation
…e=3600) GET /api/v1/meta/object/:name served `Cache-Control: public, max-age, max-age=3600`. A 1h TTL let browsers/CDNs serve a stale object schema without revalidating (the AI-build "New" form kept rendering pre-publish fields), and the directive list collided with the appended max-age into a malformed triple. getMetaItemCached now returns directives ['private','no-cache'] with no maxAge, so the ETag validator (already correct on publish) gates freshness — a cheap 304 when unchanged, fresh data the moment a publish bumps the ETag. The REST header builder strips the bare max-age placeholder before appending the real value, so a maxAge emits once as a well-formed max-age=N. 'private' keeps per-tenant metadata out of shared caches. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 15 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
Problem
GET /api/v1/meta/object/:name(and the other single-item meta reads served by the cached path) sent:Two bugs in one header:
GET /api/v1/meta/objectis uncached, which is why list views updated but single-object reads didn't.max-ageplaceholder and the REST layer appendedmax-age=3600from themaxAgefield, concatenating into the invalidpublic, max-age, max-age=3600.The ETag is already correct (it changes on publish), so the fix is to let the validator — not a TTL — gate freshness.
Fix
packages/objectql/src/protocol.ts—getMetaItemCachednow returnsdirectives: ['private', 'no-cache']with nomaxAge.no-cacheforces anIf-None-Matchrevalidation on every use (cheap304when unchanged, fresh data the instant a publish bumps the ETag);privatekeeps per-tenant metadata out of shared caches.packages/rest/src/rest-server.ts— the header builder strips the baremax-ageplaceholder before appending the real value, so a directive array +maxAgecan never collide into…, max-age, max-age=Nagain (defends all callers).Verification
Cache-Controlpublic, max-age, max-age=3600private, no-cacheEnd-to-end against a real booted showcase stack: the single-object meta endpoint now returns
private, no-cache, and replaying the ETag withIf-None-Matchreturns304 Not Modified(validator path intact; a publish bumps the ETag → fresh200).Tests (added/extended):
protocol-meta.test.ts— asserts the protocol returns['private','no-cache']with nomaxAge.rest.test.ts— asserts the emitted header isprivate, no-cache(nomax-age), plus a regression guard that['public','max-age']+maxAge:3600now yields a single well-formedpublic, max-age=3600.Context: the consumer-side symptom was previously worked around in objectui (
getObjectSchemareads withcache: 'no-cache'); this server header is the actual root cause affecting all consumers.🤖 Generated with Claude Code