perf(assets): compress asciicast responses - #839
Merged
Conversation
Serve terminal recordings as compressible text while preserving their existing cache and range behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
|
Size Change: 0 B Total Size: 6.69 MB ℹ️ View Unchanged
|
Deploying zsh with
|
| Latest commit: |
0ed5b24
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://55b68aff.zsh.pages.dev |
| Branch Preview URL: | https://ss-o-compress-asciicast.zsh.pages.dev |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Cloudflare Pages catch-all function to ensure .cast (asciicast) terminal recordings are served as text/plain; charset=utf-8 instead of application/octet-stream, enabling Cloudflare’s automatic compression for significantly smaller transfers while preserving existing caching, range, and CORS behavior.
Changes:
- Introduces a shared header helper that always applies
Content-Signaland conditionally overridesContent-Typefor.castpaths. - Applies the
.castMIME override consistently for both Pages-served assets (context.next()) and the R2 fallback response path.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
.castterminal recordings astext/plain; charset=utf-8instead ofapplication/octet-streamImpact
Cloudflare compresses
text/plainresponses but does not compress the currentapplication/octet-streamresponses. The homepage recording is 2,472,581 bytes raw and 207,708 bytes with gzip, reducing its transfer by about 91.6% (2.26 MB). Across all 15 recordings, the gzip baseline drops from 3,914,319 bytes to 351,807 bytes (91.0%).Validation
pnpm exec eslint "functions/[[path]].ts"pnpm wrangler:typecheckpnpm build:enContent-Type: text/plain; charset=utf-8for/cdn/cast/509113.castwhile retaining immutable caching and the content-signal header