-
Notifications
You must be signed in to change notification settings - Fork 2
PwaConfig
Viames Marino edited this page Feb 22, 2026
·
1 revision
Pair\Helpers\PwaConfig builds normalized runtime configuration for PairSW.js and can encode it in service-worker URL query params.
Returns baseline policy for:
offlineFallbackprecache-
cachestrategies and limits -
syncqueue/retry settings
Merges user options with defaults and clamps limits.
Produces URL-safe base64 payload for service-worker query param.
Returns SW URL with optional query keys:
offline-
pwa(encoded config)
use Pair\Helpers\PwaConfig;
$swUrl = PwaConfig::buildServiceWorkerUrl('/assets/PairSW.js', [
'offlineFallback' => '/offline.html',
'cache' => [
'pageStrategy' => 'network-first',
'apiStrategy' => 'network-first',
'assetStrategy' => 'stale-while-revalidate',
'maxRuntimeEntries' => 400
],
'sync' => [
'maxQueueEntries' => 300,
'maxAttempts' => 6
]
]);Allowed cache strategies:
network-firstcache-firststale-while-revalidate
See also: PwaManifest, PWA, PairPush.js.