Skip to main content

Service Worker

Published:

The Service Worker intercepts network requests to serve cached assets as a fallback when offline, keeping the site accessible without a network connection.

The Service Worker is intentionally disabled in local development to prevent it from interfering with live page reloads and content updates.

Configuration

All keys go under params.sw in hugo.yaml.

KeyTypeDefaultDescription
sw.enablebooleanfalseRegisters and activates the Service Worker.
sw.precache.htmlbooleanfalseProactively cache all HTML pages in the background. Pages are fetched idly (one at a time) to avoid competing with user-initiated requests. HTML requests are always served network-first with offline fallback, regardless of this setting.
sw.precache.assetsbooleanfalseProactively cache critical assets during Service Worker installation, before the user visits any page. When disabled, assets are cached on first visit.
hugo.yaml
params:
  sw:
    enable: true
    precache:
      html: true
      assets: true

Article Connections

Accessibility settings

Font size