Skip to main content

Quickstart

This example caches an HTML page at the edge, then rewrites part of it per request from a query parameter.

Updating a cache in middleware

This example writes to the cache from middleware when the incoming request is a POST, and reads the entry back from a standalone script.

Refresh and purge a cached value on demand

Expose a single URL that serves a cached JSON payload on GET, regenerates it on POST, and clears it on DELETE. Useful for cache-warming endpoints, manual invalidation hooks, or scheduled refreshes from an upstream job.
The POST handler awaits cache.put() so the acknowledgement reflects that the value actually landed. For fire-and-forget refreshes, wrap it with Bunny.v1.waitUntil(cache.put(cacheKey, fresh.clone())) and return the ack immediately.

References

Last modified on August 17, 2026