Skip to content

Add Brotli pre-compression cache for /octokit/release#1329

Merged
OpportunityLiu merged 2 commits intomasterfrom
copilot/add-compression-for-octokit-release
Mar 3, 2026
Merged

Add Brotli pre-compression cache for /octokit/release#1329
OpportunityLiu merged 2 commits intomasterfrom
copilot/add-compression-for-octokit-release

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

The /octokit/release proxy endpoint returned uncompressed JSON with no content-encoding negotiation. This adds br pre-compression with Accept-Encoding-aware responses.

Changes

  • Dual cache via shared promise: Replaces the simple unknown cache with a promise-based lock (releaseFetchPromise) that deduplicates concurrent cold-cache requests. On resolution, caches both the raw JSON string and a Brotli-compressed Buffer.
  • Async Brotli compression: Uses promisify(brotliCompress) to compress the serialized response without blocking the event loop.
  • Content negotiation: Checks Accept-Encoding on each request — returns Content-Encoding: br + compressed buffer when br is present, plain JSON string otherwise.
  • Vary: Accept-Encoding: Added so downstream caches key correctly on encoding.
  • Timer safety: Stores the expiry timer handle and guards reset/clear with a promise identity check to prevent stale timers from evicting an active cache.
GET /octokit/release
Accept-Encoding: br
→ 200  Content-Encoding: br  (pre-compressed Buffer, ~10s TTL)

GET /octokit/release
→ 200  application/json; charset=utf-8  (plain JSON string, same cache)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ehtt-editor Ready Ready Preview, Comment Mar 3, 2026 8:21am

Co-authored-by: OpportunityLiu <13471233+OpportunityLiu@users.noreply.github.com>
Copilot AI changed the title [WIP] Add compression feature to /octokit/release endpoint Add Brotli pre-compression cache for /octokit/release Mar 3, 2026
@OpportunityLiu OpportunityLiu marked this pull request as ready for review March 3, 2026 08:24
@OpportunityLiu OpportunityLiu merged commit 5ebf117 into master Mar 3, 2026
8 checks passed
@OpportunityLiu OpportunityLiu deleted the copilot/add-compression-for-octokit-release branch March 3, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants