interface for a request cache
const exampleCache: IRequestCache = { isOnline() { return (typeof window !== 'undefined' && window.navigator && window.navigator.onLine) || true; }, async fetchRequest(req: Request) { if (typeof window !== 'undefined' && window.caches) { const cache = await window.caches.open('fetch'); return cache.match(req); } return undefined; }, async storeRequest(req: Request, res: Response) { if (typeof window !== 'undefined' && window.caches && res.ok) { const cache = await window.caches.open('fetch'); req.headers.delete('Authorization'); await cache.put(req, res.clone()); } },}; Copy
const exampleCache: IRequestCache = { isOnline() { return (typeof window !== 'undefined' && window.navigator && window.navigator.onLine) || true; }, async fetchRequest(req: Request) { if (typeof window !== 'undefined' && window.caches) { const cache = await window.caches.open('fetch'); return cache.match(req); } return undefined; }, async storeRequest(req: Request, res: Response) { if (typeof window !== 'undefined' && window.caches && res.ok) { const cache = await window.caches.open('fetch'); req.headers.delete('Authorization'); await cache.put(req, res.clone()); } },};
v0.2.8
get the cached response for a request
check if the client is connected to the internet
store the response for a request
interface for a request cache
Example
Since
v0.2.8