Registry / storage / serviceworker-cache-polyfill

serviceworker-cache-polyfill

JSON →
library4.0.0jsnpmunverified

Obsolete polyfill for the ServiceWorker Cache API, specifically adding support for the `addAll` method in older browsers. Version 4.0.0 was the final release, and the project has been deprecated since 2015 as Chrome 46+ and Opera 33+ natively support `addAll`. No longer maintained; included only for legacy compatibility in applications targeting very old ServiceWorker environments.

npm install serviceworker-cache-polyfill
INSTALL
IMPORT
SIG · SERVICEWORKER-CACH
S
serviceworker-cache-polyfill
storagejavascriptv4.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

importScripts
importScripts('serviceworker-cache-polyfill.js');
<script src='serviceworker-cache-polyfill.js'></script>
Must be called inside a ServiceWorker's global scope; not a regular script tag import.

Demonstrates basic usage of the polyfill in a ServiceWorker to cache and serve responses.

// In your ServiceWorker script: importScripts('serviceworker-cache-polyfill.js'); self.addEventListener('install', function(event) { event.waitUntil( caches.open('demo-cache').then(function(cache) { return cache.put('/', new Response("From the cache!")); }) ); }); self.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request).then(function(response) { return response || new Response("Nothing in the cache for this request"); }) ); });
Debug
Known issues
deprecatedThis polyfill is obsolete and no longer maintained. Chrome 46+ and Opera 33+ support addAll natively.
fix
Remove polyfill dependency if targeting modern browsers that support the full Cache API.
affects: all
breakingThe polyfill only adds addAll support; other Cache API methods must be natively supported or polyfilled separately.
fix
Verify browser support for basic Cache API before relying on this polyfill.
affects: all
gotchaMust be loaded via importScripts inside a ServiceWorker; cannot be used in page context.
fix
Only include the script in ServiceWorker code.
affects: all
Errors
Common errors & fixes
Uncaught ReferenceError: caches is not defined
The polyfill is not loaded in a ServiceWorker context or the browser doesn't support ServiceWorker.
fix
Ensure the code runs inside a ServiceWorker script and that the browser supports ServiceWorkers.
Uncaught TypeError: cache.addAll is not a function
The polyfill wasn't loaded before calling cache.addAll.
fix
Run importScripts('serviceworker-cache-polyfill.js') earlier in the ServiceWorker script.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
serviceworker-cache-polyfill — npm install serviceworker-cache-polyfill · libregistry