Miss any of our Open RFC calls?Watch the recordings here! »

cache-control-parser

1.0.7 • Public • Published

cache-control-parser

A lightweight cache-control parser.

Coveralls github CircleCI build npm version npm monthly downloads

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:

{
  "isPublic": 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.

Install

npm i cache-control-parser

DownloadsWeekly Downloads

15

Version

1.0.7

License

MIT

Unpacked Size

9.03 kB

Total Files

7

Last publish

Collaborators

  • avatar