Registry / storage / apollo3-cache-persist-compressed

apollo3-cache-persist-compressed

JSON →
library1.0.0jsnpmunverified

A wrapper around apollo3-cache-persist that compresses Apollo Client cache data using GZip (via fflate) before persisting to storage. v1.0.0 is the current stable release; the library is actively maintained. Key differentiator: it overcomes the default 1 MB size limit of apollo3-cache-persist by compressing cache to about 6% of original size (e.g., 1 MB → 60 KB in ~22ms). Uses LocalForageWrapper drop-in replacement for seamless integration. Ships TypeScript types.

npm install apollo3-cache-persist-compressed
INSTALL
IMPORT
SIG · APOLLO3-CACHE-PERS
A
apollo3-cache-persist-compressed
storagejavascriptv1.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.

CompressedLocalForageWrapper
import { CompressedLocalForageWrapper } from 'apollo3-cache-persist-compressed'
const CompressedLocalForageWrapper = require('apollo3-cache-persist-compressed')
ESM only; CJS require will not work as package is type: module.
LocalForageWrapper
import { LocalForageWrapper } from 'apollo3-cache-persist'
import { LocalForageWrapper } from 'apollo3-cache-persist-compressed'
LocalForageWrapper is provided by apollo3-cache-persist, not this package.
default import
import AnyName from 'apollo3-cache-persist-compressed'
const AnyName = require('apollo3-cache-persist-compressed').default
Package exports only CompressedLocalForageWrapper; default import will give undefined.

Demonstrates setting up compressed cache persistence with Apollo Client, including localForage configuration and persistCache call.

import { InMemoryCache } from '@apollo/client/core'; import { persistCache } from 'apollo3-cache-persist'; import { CompressedLocalForageWrapper } from 'apollo3-cache-persist-compressed'; import localforage from 'localforage'; const cache = new InMemoryCache(); localforage.config({ driver: localforage.INDEXEDDB, name: 'apollo-cache-v2', }); await persistCache({ cache, storage: new CompressedLocalForageWrapper(localforage), serialize: true, }); const client = new ApolloClient({ cache });
Debug
Known issues
breakingCompressed storage is not backward-compatible with string-based cache. Existing uncompressed cache will be overwritten.
fix
Use a new localForage name (e.g., 'apollo-cache-v2') to avoid migration issues.
affects: all
gotchaserialize option in persistCache must be true (default). If false, compression will fail silently.
fix
Ensure serialize: true in persistCache options.
affects: all
gotchaCompressedLocalForageWrapper does not support custom serializers; it expects string data from apollo3-cache-persist.
fix
Do not use a custom serialize function; keep the default stringifier.
affects: all
deprecatedPackage is relatively new; no deprecations yet.
Errors
Common errors & fixes
Cannot find module 'apollo3-cache-persist-compressed' or its corresponding type declarations.
Missing dependency or TypeScript not resolving types.
fix
npm install apollo3-cache-persist-compressed
CompressedLocalForageWrapper is not a constructor
Using default import instead of named import.
fix
import { CompressedLocalForageWrapper } from 'apollo3-cache-persist-compressed'
localforage is not defined
localforage not installed or imported.
fix
npm install localforage ; import localforage from 'localforage'
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
apollo3-cache-persistrequiredpeer dependency; the base library providing persistCache and LocalForageWrapper
localforagerequiredrequired by CompressedLocalForageWrapper for storage
Agent activity
44 hits · last 30 days
node
38
OpenAI (training)
2
Resources
apollo3-cache-persist-compressed — npm install apollo3-cache-persist-compressed · libregistry