@avanio/variable-util
    Preparing search index...

    Interface IRequestCache

    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());
    }
    },
    };

    v0.2.8

    interface IRequestCache {
        fetchRequest(req: Request): Promise<undefined | Response>;
        isOnline(): boolean;
        storeRequest(req: Request, res: Response): Promise<void>;
    }
    Index

    Methods

    • get the cached response for a request

      Parameters

      • req: Request

      Returns Promise<undefined | Response>

    • check if the client is connected to the internet

      Returns boolean

    • store the response for a request

      Parameters

      • req: Request
      • res: Response

      Returns Promise<void>