Skip to content

fix(userscript): bypass browser HTTP cache when fetching registry index - #827

Merged
urzeye merged 1 commit into
mainfrom
fix/userscript-registry-cdn-cache
Aug 14, 2026
Merged

fix(userscript): bypass browser HTTP cache when fetching registry index#827
urzeye merged 1 commit into
mainfrom
fix/userscript-registry-cdn-cache

Conversation

@urzeye

@urzeye urzeye commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Problem

The userscript build could keep showing an outdated online adapter library for days no matter how often users checked for updates.

Root cause: jsDelivr serves branch-ref URLs (e.g. @registry-dist/index.json) with cache-control: public, max-age=604800 (7 days). GM_xmlhttpRequest goes through the browser HTTP cache, so every update check replayed the cached response and the request never reached jsDelivr. Observed in practice: a userscript stayed on registry revision 17 (published Aug 12) while the registry was already at revision 25. The raw.githubusercontent.com fallback source never kicks in because a cached response counts as success.

The extension is not affected: its registry transport already uses fetch(url, { cache: "no-store" }).

Fix

Append a timestamp query parameter to every registry request in the userscript transport. GM_xmlhttpRequest exposes no fetch cache options, and this is equivalent for our purpose: jsDelivr ignores query strings when resolving content (verified live: index.json?_=... returns the current revision), while the browser keys its HTTP cache by the full URL, so each check hits the network.

Verification

  • pnpm format:check, pnpm lint:check (no new warnings), pnpm typecheck, pnpm build:userscript all pass
  • Built ophel.user.js confirmed to contain the cache-busting parameter
  • Live check that jsDelivr serves identical content with a query string

Notes

  • Users hitting this right now can clear the browser cache to unblock the current install immediately; this fix prevents recurrence.
  • Changelog updated in both English and Chinese.

jsDelivr serves branch-ref URLs with cache-control max-age=604800 (7
days), and GM_xmlhttpRequest goes through the browser HTTP cache, so a
userscript could replay a stale registry index for days and never see
new SitePacks. The extension transport already uses fetch with
cache: no-store; the userscript transport has no such option, so append
a timestamp query parameter instead: jsDelivr ignores query strings
when resolving content, while the browser keys its cache by full URL.
@urzeye urzeye self-assigned this Aug 14, 2026
@urzeye urzeye added the bug Something isn't working label Aug 14, 2026
@urzeye urzeye added this to the v1.2.1 milestone Aug 14, 2026
@urzeye
urzeye merged commit e586540 into main Aug 14, 2026
1 check passed
@urzeye
urzeye deleted the fix/userscript-registry-cdn-cache branch August 14, 2026 15:05
@github-project-automation github-project-automation Bot moved this from Todo to Done in Ophel Development Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant