Generate browser and CDN cache header values as Express middleware. Version 1.1.1 (latest, stable). Low-activity package (no recent updates). Supports route-level and app-level configuration with glob patterns. Key differentiator: provides sensible defaults for Cache-Control, Surrogate-Control, and Last-Modified headers with options like stale-while-revalidate and stale-if-error for advanced caching strategies. Requires core-js peer dependency. Not actively maintained.
npm install cache-headersNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows app-level middleware setup with path-based cache configuration for Express.
Understand that Cache-Control and Surrogate-Control are set separately; maxAge only affects Surrogate-Control.
Consider using a newer caching middleware or update peer dependency to core-js v3 if compatible, or avoid using core-js polyfills globally.
Explicitly set maxAge to desired value but note that setting private forces maxAge=0. See documentation.
Test glob patterns thoroughly or use simpler path structures.
If Last-Modified override is needed, handle it separately in route handler.
Run: npm install core-js@^2.4.1
Ensure correct require: const cache = require('cache-headers'); and that the package is installed.Check that maxAge is set correctly and that staleRevalidate/staleError are not overriding Cache-Control behavior.
If you want no caching, use false; if you want public caching, set a numeric maxAge or object with setPrivate: false.