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

cache-kit

v1.2.3

Published

A simple caching layer for fetch requests — supports memory, browser (localStorage), and Node.js (filesystem) adapters with smart strategies.

Readme

⚡ cache-kit

A smart caching layer for fetch requests — supports memory, browser (localStorage), and Node.js (filesystem) with modern caching strategies.


📦 Installation

npm install cache-kit

Or use it directly in the browser via CDN:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/cdn/cache-kit.min.js"></script>

✨ Features

  • 🌐 Only supports GET requests (for now)
  • 📁 Adapters:
    • memory: In-memory (Node/React/Next.js)
    • browser: Uses localStorage
    • node: Filesystem caching in .cache/
  • 🧠 Strategies:
    • cache-first: Serve cache if available, fetch if not
    • network-first: Try network first, fallback to cache on failure
    • stale-while-revalidate: Serve stale cache immediately, fetch and update in background
  • 🕒 TTL support: Set revalidation interval in seconds
  • 🧩 Core logic in: cacheManager.ts

📌 Quick Usage

Node.js

import { cachedFetch } from 'cache-kit';

(async () => {
  const res = await cachedFetch('https://api.example.com/data',
    { method: 'GET' },
    {
      adapter: 'node',
      strategy: 'cache-first',
      revalidate: 300
    }
  );

  const data = await res.json();
  console.log(data);
})();

React / Next.js

useEffect(() => {
  (async () => {
    const res = await cachedFetch('/api/user', { method: 'GET' }, {
      adapter: 'browser',
      strategy: 'stale-while-revalidate',
      revalidate: 60
    });
    const data = await res.json();
    setData(data);
  })();
}, []);

Vanilla Browser (via CDN)

<script src="https://cdn.jsdelivr.net/npm/[email protected]/cdn/cache-kit.min.js"></script>
<script>
  (async () => {
    const res = await window.cacheKit.cachedFetch('https://api.example.com/data',
      { method: 'GET' },
      {
        adapter: 'browser',
        strategy: 'network-first',
        revalidate: 60
      }
    );
    const data = await res.json();
    console.log(data);
  })();
</script>

🔧 API

cachedFetch(url, options, cacheOptions)

options: RequestInit

  • Only method: 'GET' is supported.

cacheOptions: CacheProps

| Property | Type | Description | |--------------|--------------------------------------------------------|--------------------------------| | revalidate | number | TTL (cache expiry in seconds) | | strategy | 'cache-first' | 'network-first' | 'stale-while-revalidate' | Caching strategy | | adapter | 'memory' | 'browser' | 'node' | Cache storage backend |


📁 Project Structure (Simplified)

cache-kit/
├── adapters/
│   ├── browser.ts
│   ├── memory.ts
│   └── node.ts
├── utils/
│   ├── common.util.ts
│   └── cache.util.ts
├── cacheManager.ts
├── index.ts
├── types.ts

🚧 Future Scope

  • [ ] Add support for non-GET methods (POST, PUT, etc.)
  • [ ] Automatic cache invalidation on triggers
  • [ ] Custom cache key generator
  • [ ] More storage backends (e.g., IndexedDB)
  • [ ] Tag-based cache invalidation

🤝 Contributing

Contributions are welcome! Feel free to open issues, submit pull requests, or suggest enhancements.


📄 License

MIT — free to use.