The `nocache` package is an Express/Connect middleware designed to aggressively disable client-side caching by setting specific HTTP response headers. It is currently at stable version 4.0.0. As a component of the Helmet.js suite, its release cadence is generally tied to Helmet's, focusing on stability and security rather than frequent feature additions, with major version updates typically aligning with Node.js EOLs or significant breaking changes. Its primary differentiator is its simplicity and integration within the broader Helmet.js ecosystem, providing a straightforward, opinionated way to ensure clients always request fresh resources. This is crucial for applications sensitive to stale data, enforcing immediate updates, or handling sensitive information that should never reside in a browser cache. It effectively sets `Cache-Control`, `Expires`, and `Surrogate-Control` headers.
npm install nocacheVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize an Express application and apply the `nocache` middleware globally, ensuring all HTTP responses include headers designed to disable client-side caching.
Upgrade your Node.js environment to version 16.0.0 or higher to ensure compatibility and access the latest features and security updates.
Carefully consider where `nocache` is applied. For static assets or content that changes infrequently, consider applying `nocache` only to specific routes (e.g., `app.get('/admin', nocache(), ...)`) or using more granular cache control strategies.Review the order of middleware in your application and the configuration of your web server/proxy. Ensure `nocache` is applied at a point where its headers will not be overridden by subsequent processes if you intend for it to be the authoritative cache control mechanism.
The `nocache` export is a factory function that returns the actual middleware. You must call it, even with no arguments, before passing its result to `app.use()`: `app.use(nocache());`.
No dependency data recorded yet.