Skip to content

Fix service worker downloading ~100 MB on first visit - #1630

Open
Akshats-git wants to merge 1 commit into
processing:mainfrom
Akshats-git:fix/service-worker-precache
Open

Akshats-git wants to merge 1 commit into
processing:mainfrom
Akshats-git:fix/service-worker-precache

Conversation

@Akshats-git

@Akshats-git Akshats-git commented Oct 23, 2026 •

Copy link
Copy Markdown

Fixes #1621

The service worker was precaching every image and search index, so a first visit quietly downloaded ~112 MB (the page itself is ~2.5 MB). It also never cached pages for offline use, because its rule only matched .html URLs and ours end in /.

Changes

  • Precache only CSS, JS and fonts: 838 files / 112.7 MB becomes 82 files / 3.75 MB.
  • Cache pages with a network-first rule that matches navigations. Visited pages now work offline, and online visitors never get a stale page.
  • Cache search indices as they're used, so only the language someone actually searches gets stored (thanks @davepagurek for the suggestion).
  • Turn on navigationPreload so page loads don't wait for the worker to start.
  • Remove the unused ar, pt-br and sk search indices. Nothing builds or loads them.

Testing

Built the site and checked it in Chromium (Playwright) against npm run preview:

  • First visit: the worker downloads 1.4 MB instead of ~104 MB.
  • Visited reference, localized and search pages reload offline. A page never visited fails offline, as expected.
  • With the old worker's 113.7 MB cache installed, switching to this one drops storage to 3.9 MB with no action from the user.
  • Lint, npm run check (0 errors), npm test (63 passing) and the production build all pass.

The v1 branch has the same config, so it needs the same change. Happy to open a follow-up PR for that.

AI use: I used Claude Code to help investigate and validate the changes.

The precache pattern pulled in every image and search index (~112 MB)
on a first visit. Precache only CSS, JS and fonts (~4 MB) instead.

- Cache visited pages with a network-first rule that matches
  navigations, so they work offline without serving stale pages.
- Cache only the search index for the language being used.
- Remove the unused ar, pt-br and sk search indices.

Fixes processing#1621
Copilot AI balanced review requested due to automatic review settings October 23, 2026 05:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
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.

Service worker downloads around 100 MB on first visit and doesn't enable offline use

2 participants