npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pip-webui2-cache

v1.1.1

Published

![](https://img.shields.io/badge/license-MIT-blue.svg)

Readme

Caching tools

pip-webui2-cache module contains cache behavior
DEMO is HERE

Usage

To start using cache you should:

Step 1

Include module into your application module. PipCacheModule.forRoot(config?: PipCacheModuleConfig).
Config has this optional properties:

  • enableLogs - turn on/off logs to console
  • prefix - custom prefix for IndexedDB database name

Step 2

Provide model(s) description through InjectionToken PIP_CACHE_MODEL with enabled flag multi.
Structure of PipCacheModel:

class PipCacheModel {
    name: string;
    options: {
        maxAge: number;
        key?: string;
    };
    interceptors: {
        item?: PipCacheInterceptorItemSettings;
        collection?: PipCacheInterceptorCollectionSettings;
    };
}

class PipCacheInterceptorOptions {
    maxAge?: number;
}

class PipCacheInterceptorSettings {
    match: RegExp;
    options?: PipCacheInterceptorOptions;
}

class PipCacheInterceptorItemSettings extends PipCacheInterceptorSettings {
    getKey: (groups: any) => any;
}

class PipCacheInterceptorCollectionSettings extends PipCacheInterceptorSettings {
    responseModify?: {
        responseToItems: (resp: any) => any[];
        itemsToResponse: (items: any[]) => any;
    };
    extractPagination?: (params: HttpParams) => [PipCachePaginationParams, HttpParams];
}

Description:

  • name - name of model. Module will use this name with prefix as database name;
  • options:
    • maxAge - how long item will remain in cache;
    • key - custom key field different from id which is default
  • interceptors - how cache will intercept requests:
    • item - how cache will intercept request for single item:
      • match - regular expression to catch single item request. It HAVE TO contain named group like /items\/(?<id>[^ $\/]*)/ to get key from request;
      • options - custom options to overwrite model options;
      • getKey - function to retrieve key from groups received by matching regular expression of url.
    • collection - how cache will intercept request for collection of items:
      • match - regular expression to catch single item request. It HAVE TO contain named group like /items\/(?<id>[^ $\/]*)/ to get key from request;
      • options - custom options to overwrite model options;
      • responseModify - functions to modify response if items returned in some property of response, not array;
      • extractPagination - extract pagination params from request params. Make sure to delete this params in request params and return them

Example:

export getPhotosKey(groups: any) { return groups && groups.length > 1 && groups[1]; }
export function extractPhotosPagination(params: HttpParams): [PipCachePaginationParams, HttpParams] {
  const res = new PipCachePaginationParams();
  if (params) {
    if (params.has('p') && params.has('l')) {
      res.limit = parseInt(params.get('l'), 10);
      res.offset = (parseInt(params.get('p'), 10) - 1) * res.limit;
      params = params.delete('p');
      params = params.delete('l');
    }
  }
  return [res, params];
}
// ...
{
  provide: PIP_CACHE_MODEL,
  useValue: {
    name: 'photos',
    options: {
      maxAge: 1000 * 60 * 2, // 2 minutes
      key: 'id' // key 'id'
    },
    interceptors: {
      item: {
        match: new RegExp('photos/([^\/]+)$'), // Catch all requests and look for id
        getKey: getPhotosKey  // return 'id' from RexExp match
      },
      collection: {
        match: new RegExp('photos'), // Catch all requests and look for 'photos' in request
        extractPagination: extractPhotosPagination // Custom params extractor
      }
    }
  } as PipCacheModel,
  multi: true
}

NB! All interceptors will be checked until some of them will match. If there's no interceptors found - cache won't apply. Interceptors order is important, item should be always before collection, because it has more detailed url to match.