feat(code.gs): optional spreadsheet-backed response cache with TTL#443
Merged
therealaleph merged 2 commits intotherealaleph:mainfrom Apr 28, 2026
Merged
feat(code.gs): optional spreadsheet-backed response cache with TTL#443therealaleph merged 2 commits intotherealaleph:mainfrom
therealaleph merged 2 commits intotherealaleph:mainfrom
Conversation
therealaleph
added a commit
that referenced
this pull request
Apr 28, 2026
…er errors Three substantive PRs from contributors landed for this release: - #443 by @euvel: optional spreadsheet-backed response cache in Code.gs. Implements all 5 review suggestions from the design discussion (#400): TTL-aware caching, 35 KB body-size gate, header rewriting on hit, circular buffer for O(1) writes, Vary-aware compound keys. - #439 by @dazzling-no-more: bypass Apps Script tunnel for known DoH endpoints on TCP/443. Cloudflare/Google/Quad9/AdGuard/NextDNS/OpenDNS/ CleanBrowsing/dns.sb/dns0.eu/AliDNS/doh.pub/Mullvad. Saves the ~2s UrlFetchApp roundtrip per name without losing privacy (DoH is already encrypted). Default on; users can opt out via tunnel_doh: true or extend the list via bypass_doh_hosts. - #438 by @dazzling-no-more: H1 container keepalive + 431 oversized- headers + clearer port-collision message. Cherry-picks from upstream Python (Apr 23-26 window). Keepalive prevents Apps Script V8 cold starts (visible as YouTube stalls after pause); 431 replaces silent socket drops on >64 KB headers (which caused browser retry loops).
Owner
|
Merged + included in v1.8.3 (just tagged). Builds clean, all 160 tests pass on main. Thanks for shipping this — exactly the kind of contribution that scales the project beyond what one maintainer can ship alone. v1.8.3 release page: https://github.com/therealaleph/MasterHttpRelayVPN-RUST/releases/tag/v1.8.3 Telegram channel announcement: https://t.me/mhrv_rs (will fire once release CI completes) Will tag you on the v1.9.0 xmux design issue when drafted (~1-2 weeks). [reply via Anthropic Claude | reviewed by @therealaleph] |
This was referenced Apr 29, 2026
This was referenced Apr 29, 2026
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
Adds an optional spreadsheet-backed response caching layer to
Code.gsthat reducesUrlFetchAppquota consumption by serving repeat public GET requests from a Google Sheet.All five review suggestions from the discussion thread are addressed:
_parseMaxAge()readsCache-Control: max-age, respectsno-cache/no-store/private, stores anExpires_Atcolumn, and skips expired entries on lookup. Falls back to 24 hours when noCache-Controlheader is present.CACHE_MAX_BODY_BYTES = 35000prevents hitting the 50,000-character Sheets cell limit. Oversized responses are returned to the user but skipped for storage.Date,Age, andCache-Controlare recalculated to reflect time-since-cache. OriginalCache-Controlis preserved inX-Original-Cache-Control. Diagnostic headersX-Cache: HIT from relay-spreadsheetandX-Cached-Atare added.RelayMetasheet tracks a write cursor that wraps atCACHE_MAX_ROWS. ReplacesappendRow/deleteRows, eliminating reindexing overhead.Accept-EncodingandAccept-Languageare hashed alongside the URL using case-insensitive matching and whitespace normalization. Covers ~95% of real-worldVaryusage without inspecting the response.Design Discussion
See this issue thread for full discussion and reviewer feedback.
Configuration
Opt-in via a single constant at the top of
Code.gs:const CACHE_SPREADSHEET_ID = "YOUR_SPREADSHEET_ID_HERE";Leave as-is to disable caching entirely — zero overhead, no behavioral change for existing deployments.
How to Test
Breaking Changes
None. The cache is off by default.