Docs on GitHub

Simple, Automatic Request Caching

swimple provides automatic caching with smart invalidation for your service worker.

⚡ Low Configuration

Request caching with automatic invalidation by default - minimal setup required

🔄 Smart Invalidation

Automatically invalidate cache on mutations (POST/PATCH/PUT/DELETE)

đŸŽ›ī¸ Flexible Strategies

Support for cache-first, network-first, and stale-while-revalidate

đŸĒļ Lightweight

Single-purpose library with no dependencies

Try It Out

Make API requests and watch them get cached automatically. Try mutations to see cache invalidation in action.

Click a button above to make an API request...

Cache Inspector

These are the entries in the browser's cache that swimple has handled.

Loading cache entries...

Quick Start

// sw.js
import { createHandleRequest } from "https://cdn.jsdelivr.net/npm/swimple@1.0.0/index.js";

const handleRequest = createHandleRequest({
  cacheName: "sw-cache-v1",
  scope: ["/api/"]
});

self.addEventListener("fetch", (event) => {
  const response = handleRequest(event);
  if (response) {
    event.respondWith(response);
  }
});