@work-bee/cache-control
@work-bee/cache-control
Middleware that respects HTTP Cache-Control headers to determine caching behavior.
Install
npm install @work-bee/cache-control Usage
import { compileConfig, strategyCacheFirst } from "@work-bee/core";
import cacheControlMiddleware from "@work-bee/cache-control";
const cacheControl = cacheControlMiddleware({
cacheControl: "max-age=60",
});
const config = compileConfig({
strategy: strategyCacheFirst,
middlewares: [cacheControl],
}); Options
| Option | Type | Required | Description |
|---|---|---|---|
cacheControl | string | Yes | Cache-Control header value (e.g. "max-age=60", "no-cache") |
Returns
{ afterNetwork }
Behavior
max-age=0orno-cache- bypasses cache, fetches from networkmax-age=N- uses cached response if not expired- No
Cache-Controlheader - falls through to default strategy