Turning off the service worker debug logging
If you opened the browser console on gongju.dev you were met with an endless stream of lines about precaching. Here is why, and what changed.
What was happening
The PWA plugin shipped with debug: true in the Docusaurus config. Workbox only prints its internal trace in debug mode, so every page load dumped the entire precache cycle into the console:
workbox Network request for '/en/docs/business/qrcode.html' returned a response with status '200'.
workbox The response for ... has a 'Vary: accept-encoding' header. Consider setting
the {ignoreVary: true} option on your strategy ...
workbox Updating the 'workbox-precache-v2-https://gongju.dev/en/' cache with a new Response ...
workbox No cached response found in 'workbox-precache-v2-https://gongju.dev/en/'.
It is noisy rather than broken, but it is a wall of noise on a production site and it buried anything you actually wanted to look at.
The fix
One flag. The same setting also controls how the service worker itself is bundled, so turning it off does three things at once:
- Silences the Workbox logger, which is what prints those lines
- Switches the worker from a development build to a production build (
mode: 'development'→'production') - Minifies the worker and drops its source map — the deployed
sw.jswas 258 KB raw because it shipped unminified
The precache behaviour itself is untouched. Nothing about which pages or assets get cached has changed.
Still on the list
Two things about the PWA setup are worth a look separately, and neither is fixed here:
- The worker precaches every HTML page on the site — 181 of them under
/en/, and each locale has its own worker. That is a few MB on a visitor's first load, for an offline mode that only activates when the PWA is installed or launched in standalone mode. - Cloudflare adds
Vary: accept-encodingwhen it applies Brotli compression, which Workbox flags because it can prevent precached entries from being matched later. Fixable withignoreVary, but that is a behavioural change and wants testing on its own.
