Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ulisesgascon/simple-cache-control-middleware
A very simple cache control middleware for express
https://github.com/ulisesgascon/simple-cache-control-middleware
cache cache-control express express-middleware
Last synced: 26 days ago
JSON representation
A very simple cache control middleware for express
- Host: GitHub
- URL: https://github.com/ulisesgascon/simple-cache-control-middleware
- Owner: UlisesGascon
- License: mit
- Created: 2023-03-21T07:43:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-03-21T09:10:15.000Z (over 1 year ago)
- Last Synced: 2024-10-13T04:34:23.550Z (about 1 month ago)
- Topics: cache, cache-control, express, express-middleware
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/simple-cache-control-middleware
- Size: 63.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
simple-cache-control-middleware
A very simple cache control middleware for express# About
A very simple cache control middleware for express.
โค๏ธ Awesome Features:
- Easy to define the max-age ๐ฅ
- Only GET Request are cached ๐บ
- `debug` is supported ๐ช
- Easy to use and great test coverage โ## Usage
### Install
```bash
npm install simple-cache-control-middleware
```### Default
```js
const 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!');
});
```### Custom max-age
```js
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
}))
```## Built With
Development only:
- [Standard](https://www.npmjs.com/package/standard) - Linting
- [Jest](https://www.npmjs.com/package/jest) Testing frameworkProduction only:
- [debug](https://www.npmjs.com/package/debug) - Debug the app
## ContributingPlease read [CONTRIBUTING.md](https://github.com/UlisesGascon/user-language-middleware/blob/main/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/ulisesGascon/simple-cache-control-middleware/tags).
## Authors
- **Ulises Gascรณn** - *Initial work- - [@ulisesGascon](https://github.com/ulisesGascon)
See also the list of [contributors](https://github.com/ulisesGascon/simple-cache-control-middleware/contributors) who participated in this project.
## License
This project is licensed under the GNU AGPL3.0 License - see the [LICENSE.md](LICENSE.md) file for details
## Acknowledgments
Heavily inspired in [RegBrain | Cache headers in Express js app
](https://regbrain.com/article/cache-headers-express-js) post