
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
cache-parser
Advanced tools
cache-parser
is a minimal parser for the Cache-Control headernpm install --save cache-parser
# or
yarn add cache-parser
const { parse, tokenize } = require('cache-parser');
// or
import { parse, tokenize } from 'cache-parser';
<script
crossorigin
src="https://cdn.jsdelivr.net/npm/cache-parser@1/index.umd.js"
></script>
<!-- or -->
<script crossorigin src="https://unpkg.com/cache-parser@1/dist/index.umd.js"></script>
const { parse, tokenize } = window.CacheParser;
This library consists of two important functions: parse
and
tokenize
.
This is a pretty straightforward library, so, every documentation needed by every piece of
code is in form of TSDoc
and JSDoc
comments.
Simple header parsing:
import { parse } from 'cache-parser';
const rawHeader = 'public, max-age=3600';
const { public, maxAge, immutable } = parse(rawHeader);
console.log(public); // true
console.log(maxAge); // 3600
console.log(typeof maxAge); // number
console.log(immutable); // undefined
Simple header building:
import { tokenize } from 'cache-parser';
/** @type {import('cache-parser').CacheControl} */
const cacheProperties = { public: true, maxAge: 3600 };
// ['public', 'max-age=3600']
const cacheTokens = tokenize(cacheProperties);
// 'public, max-age=3600'
response.headers['Cache-Control'] = tokens.join(', ');
Licensed under the MIT. See LICENSE
for more informations.
See my contact information on my github profile or open a new issue.
FAQs
A minimal parser for the Cache-Control header.
The npm package cache-parser receives a total of 118,031 weekly downloads. As such, cache-parser popularity was classified as popular.
We found that cache-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.