Repository navigation
perf: cache the artifact shell, minify its inner renderer, and prefetch it early - #26
Merged
Merged
Conversation
Emit a _headers file into the host-cloudflare dist only. /assets/* is cached for a year; the stable-named shell copy keeps revalidating. Claude-Session: https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S
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.
Why
Opening an artifact downloaded the MCP-Apps shell document again on every view: it is about 4.7 MB raw (about 950 KB gzip), and hashed assets were served with
max-age=0, must-revalidateand no ETag. On a cold open the download also waited for the artifact row, because the iframe mounts only after the row arrives.What changes
_headers./assets/*(content-hashed) becomespublic, max-age=31536000, immutable. The stable-named shell copy read by the MCP session keeps revalidating.bundleInnerRendererminifies in production. The shell drops from 4,720,043 B to 2,733,014 B raw, and from 968,294 B to 755,385 B gzip. The smoke harness stays unminified.preloadArtifactRendereradds one<link rel="prefetch">for the shell document once the renderer chunk resolves. The shell module exportsshellHtmlUrl, so the document download overlaps the row fetch.packages/reactstill does not import the shell package.Tests
artifact-renderer.test.tsx: one prefetch link per URL, and none when no URL is announced.vite.test.tspasses.https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S