express-cache-controller is an Express.js middleware designed to simplify the management of Cache-Control HTTP headers for client-side caching. It offers a straightforward API to configure directives such as `max-age`, `no-cache`, `no-store`, `public`, and `private` globally for an application or on a per-route basis via `res.cacheControl`. The package is lightweight and focuses solely on setting response headers to guide browser and proxy caching behavior. The current stable and only version, 1.1.0, was last published in October 2017, indicating it is effectively an abandoned project with no ongoing development or official support. Users integrating this package into modern Node.js environments should be aware of its CommonJS-only nature and the absence of recent security patches or feature enhancements compared to more actively maintained caching solutions.
npm install express-cache-controllerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting global `Cache-Control` defaults, overriding them per-route, disabling caching, and applying specific cache settings to error responses.
Ensure your project uses CommonJS (`require`) for importing `express-cache-controller` or configure your build system to handle CommonJS modules in an ESM context.
For new projects or applications requiring ongoing support and security, consider more actively maintained Express caching solutions or implementing `Cache-Control` headers manually.
If server-side caching is required to reduce backend load or improve response times by serving pre-computed results, integrate a separate server-side caching solution (e.g., Redis, `node-cache`, `express-response-cache`).
Place `express-cache-controller` middleware early in your Express application's middleware stack. If specific routes need different headers, set `res.cacheControl` *after* this middleware has run, but before `res.send()` or `res.end()`.
Correct usage is `const cacheControl = require('express-cache-controller'); app.use(cacheControl(options));`Ensure `app.use(cacheControl())` is called early in your Express app. Verify `res.cacheControl = { ... }` is used correctly for overrides. Inspect network requests to confirm the header is being sent as expected and debug for conflicting middleware.This package is CommonJS. Use `const cacheControl = require('express-cache-controller');` at the top of your file. If you must use ESM, consider wrapping it or finding a more modern alternative.No dependency data recorded yet.