Registry / storage / cache-polyfill

cache-polyfill

JSON →
library1.0.1jsnpmunverified

A polyfill for the Cache and CacheStorage APIs, wrapping IndexedDB for offline storage without requiring HTTPS/SSL. Current stable version: 1.0.1. No active release schedule. Key differentiators: works without SSL, supports older browsers, and provides a drop-in replacement for the native Cache API used in Service Workers.

npm install cache-polyfill
INSTALL
IMPORT
SIG · CACHE-POLYFILL
C
cache-polyfill
storagejavascriptv1.0.1
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.

Cache
import { Cache } from 'cache-polyfill'
const Cache = require('cache-polyfill').Cache
ESM only; no default export.
CacheStorage
import { CacheStorage } from 'cache-polyfill'
import CacheStorage from 'cache-polyfill'
Named export only.
caches
import { caches } from 'cache-polyfill'
const caches = require('cache-polyfill')
The caches global is exported as a named export.

Shows opening a cache, adding resources, and matching a request using the polyfill.

import { caches } from 'cache-polyfill'; caches.open('v1').then(cache => { cache.addAll([ '/index.html', '/style.css', '/app.js' ]); }); caches.match('/index.html').then(response => { if (response) { console.log('Found in cache:', response); } else { console.log('Not in cache'); } });
Debug
Known issues
deprecatedPackage is no longer maintained. Use native Cache API when available (HTTPS/secure context) or a more modern polyfill.
fix
Migrate to native Cache API or use 'cache-polyfill-broken'? No clear fix.
affects: >=0.0.0
gotchaOperates on IndexedDB, so storage limits apply. May fail silently if IndexedDB is unavailable.
fix
Ensure IndexedDB is supported or implement fallback.
affects: >=0.0.0
gotchaDoes not support all Cache API features (e.g., cache.addAll may not work in older browsers without fetch polyfill).
fix
Include a fetch polyfill from 'whatwg-fetch'.
affects: >=0.0.0
Errors
Common errors & fixes
Uncaught ReferenceError: caches is not defined
Importing the polyfill incorrectly, or running in an environment without module support.
fix
Use ES modules: import { caches } from 'cache-polyfill'.
Failed to execute 'addAll' on 'Cache': The operation is insecure.
Using the polyfill in a non-secure context without a fetch polyfill.
fix
Import 'whatwg-fetch' before using cache-polyfill.
TypeError: Failed to execute 'match' on 'Cache': parameter 1 is not of type 'Request'.
Passing a string URL instead of a Request object to caches.match().
fix
Use caches.match(new Request(url)) or caches.match(url) (if polyfill supports string, but for safety use Request).
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
whatwg-fetchoptionalRequired for fetch API used in cache operations
Agent activity
31 hits · last 30 days
node
28
Resources
cache-polyfill — npm install cache-polyfill · libregistry