2.9.0 • Published 2 years ago

@d1testflare/cache v2.9.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@d1testflare/cache

Cache module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers. See ✨ Cache for more details.

Example

import { Cache } from "@d1testflare/cache";
import { Response } from "@d1testflare/core";
import { MemoryStorage } from "@d1testflare/storage-memory";

const cache = new Cache(new MemoryStorage());

const key = "http://localhost";
const res = new Response("body", {
  headers: { "Cache-Control": "max-age=3600" },
});
await cache.put(key, res);

const cachedRes = await cache.match(key);
console.log(await cachedRes.text()); // body