cache-control-parser
A lightweight cache-control parser.

Features
- No dependencies
- Built-in TypeScript support
- Thoroughly tested
Getting Started
Installation
To use cache-control-parser in your project, run:
npm install cache-control-parser
Usage
import cacheControlParser from "cache-control-parser";
const cacheControl = cacheControlParser(
"public, max-age=86400, no-transform"
);
console.log(cacheControl);
Output:
{
"public": true,
"maxAge": 86400,
"noTransform": true
}
Supported cache-control directives:
{
maxAge?: number;
sharedMaxAge?: number;
staleWhileRevalidate?: number;
staleIfError?: number;
isPublic?: boolean;
isPrivate?: boolean;
noStore?: boolean;
noCache?: boolean;
mustRevalidate?: boolean;
proxyRevalidate?: boolean;
immutable?: boolean;
noTransform?: boolean;
}
TypeScript
Type definitions are included in this library and exposed via:
import { CacheControl } from "cache-control-parser";
Built with
- node.js - Cross-platform JavaScript run-time environment for executing JavaScript code server-side.
- TypeScript - Typed superset of JavaScript that compiles to plain JavaScript.
- Jest - Delightful JavaScript Testing.
Contributing
When contributing to this project, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Update the README.md with details of changes to the library.
Execute yarn test and update the tests if needed.
Testing
Run the full test suite:
yarn test
Run tests in watch mode:
yarn test:watch
Authors
License
This project is licensed under the MIT License - see the LICENSE file for details.