A very simple cache control middleware for express
A very simple cache control middleware for express.
❤️ Awesome Features:
- Easy to define the max-age 🔥
- Only GET Request are cached 🍺
debugis supported 💪- Easy to use and great test coverage ✅
npm install simple-cache-control-middlewareconst express = require('express');
const simpleCacheControlMiddleware = require('simple-cache-control-middleware')
const app = express();
app.use(simpleCacheControlMiddleware())
app.get('/', (req, res) => {
res.send(`This request has 5m max-age`);
});
app.post('/', (req, res) => {
res.send(`This request is not cached`);
});
app.listen(3000, () => {
console.log('We are in port 3000!');
});const express = require('express');
const simpleCacheControlMiddleware = require('simple-cache-control-middleware')
const app = express();
const TEN_MINUTES = 60 * 10
app.use(simpleCacheControlMiddleware({
maxAge: TEN_MINUTES
}))Development only:
Production only:
- debug - Debug the app
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Ulises Gascón - *Initial work- - @ulisesGascon
See also the list of contributors who participated in this project.
This project is licensed under the GNU AGPL3.0 License - see the LICENSE.md file for details
Heavily inspired in RegBrain | Cache headers in Express js app post