fix: skip runtime buffer cache during prerender (#613)#626
Merged
Conversation
The root trigger for #613: during prerender the buffer cache reaches for the configured backend, but a Cloudflare KV binding only exists at runtime in the Worker, not in the Node build environment — hence `Invalid binding KV: undefined`. The graceful degradation added here catches that, but prerender shouldn't touch the runtime cache at all: prerendered images are written to static files served via the `/_og/s/**` route rule, which already sets immutable caching. Disable the buffer cache when `import.meta.prerender` is set, and skip the no-store headers in that case so the static output keeps the route rule's caching policy instead of being marked uncacheable.
commit: |
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.
🔗 Linked issue
Follow-up to #619 / #613.
❓ Type of change
📚 Description
#619 made the cache degrade gracefully when the backend is unreachable, which stops the build from failing. This is the cleaner companion fix: don't use the runtime buffer cache during prerender at all.
The
Invalid binding KV: undefinedin #613 fires during prerender because the buffer cache reaches for the configured backend, but a Cloudflare KV binding only exists at runtime in the Worker, not in the Node build environment doing the prerender. Beyond Cloudflare, this is correct for every preset: prerendered images are written to static files served by the/_og/s/**route rule (immutable, max-age=1yr), so the runtime buffer cache is irrelevant to serving them.import.meta.prerenderfromintentionallyEnabled, so prerender never touches the runtime cache backend.no-storeheader block during prerender, so the static output keeps the route rule's long-cache policy instead of being marked uncacheable.This got left out of #619 when it merged (PR head-ref lag merged the prior commit), hence the standalone PR. With this, the reporter's
runtimeCacheStorage: falseworkaround is no longer needed.