Registry / devops / parse-cache-control

parse-cache-control

JSON →
library1.0.1jsnpmunverified

A lightweight, dependency-free function to parse HTTP Cache-Control headers, extracted from the hapi.js Wreck HTTP client. Version 1.0.1 is stable but unmaintained since 2016. Key differentiator: returns a simple object with parsed directives, no frills. Simpler than dedicated HTTP caching libraries, but limited to basic parsing.

npm install parse-cache-control
INSTALL
IMPORT
SIG · PARSE-CACHE-CONTRO
P
parse-cache-control
devopsjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import parseCacheControl from 'parse-cache-control'
const { parseCacheControl } = require('parse-cache-control')
Package exports a single function as default export. No named exports.
default (CommonJS)
const parseCacheControl = require('parse-cache-control')
CommonJS works fine; package does not provide ESM.
TypeScript usage
// @ts-ignore import parseCacheControl from 'parse-cache-control';
import parseCacheControl from 'parse-cache-control';
Package has no TypeScript types. You may need a declare module or skip type checking.

Demonstrates basic usage: parse a Cache-Control header string into an object of directives.

const parseCacheControl = require('parse-cache-control'); const header = 'public, max-age=31536000, s-maxage=86400'; const parsed = parseCacheControl(header); console.log(parsed); // Output: // { public: true, // 'max-age': '31536000', // 's-maxage': '86400' }
Debug
Known issues
deprecatedPackage is unmaintained since 2016. No updates or security patches.
fix
Consider using a maintained alternative like 'http-cache-semantics' or 'cache-control-parser'.
affects: *
gotchaBoolean directives (e.g., 'public', 'no-cache') return true; numeric directives return strings, not numbers.
fix
Parse numeric values manually, e.g., parseInt(parsed['max-age'], 10).
affects: <=1.0.1
gotchaInput header is case-sensitive? No, but directive names are normalized to lowercase. Spaces in directives may cause unexpected results.
fix
Trim input and remove extra spaces.
affects: *
gotchaNo support for quoted string values (e.g., private="set-cookie").
fix
Expect only simple token values.
affects: *
Errors
Common errors & fixes
TypeError: parseCacheControl is not a function
Using named import when package exports a default function.
fix
Use default import: import parseCacheControl from 'parse-cache-control'
Cannot find module 'parse-cache-control'
Package not installed or incorrectly required.
fix
Run: npm install parse-cache-control
parsed.max-age gives a string instead of number
Package returns all values as strings, even numeric ones.
fix
Convert to number: Number(parsed['max-age'])
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
parse-cache-control — npm install parse-cache-control · libregistry