pretty-cache-header is a JavaScript/TypeScript utility designed to simplify the creation of `Cache-Control` HTTP headers by parsing human-readable time strings into seconds. It aims to reduce errors by leveraging TypeScript's Template Literal Types to provide strong type-safety for time string formats, ensuring developers pass valid patterns like '1week' or '30days'. The package is currently at version 1.0.0, indicating its initial stable release. As a lightweight utility with a focused purpose, its release cadence is expected to be driven by bug fixes or minor enhancements rather than frequent major updates. Its key differentiator is the combination of human-readable time strings with robust type-checking, making it particularly useful in TypeScript-heavy projects where maintainability and type safety are priorities, especially when configuring server responses or CDN caching policies.
npm install pretty-cache-headerVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use `cacheHeader` to generate a `Cache-Control` string with human-readable time values and common directives.
Refer to the `TimeString format` section in the documentation for exact valid patterns. Always use a number immediately followed by a unit keyword (e.g., '5days', '30mins').
Review existing cache header logic and refactor time durations to use the `TimeString` format (e.g., '1day' instead of `86400`) where applicable, or pass numerical seconds for directives that accept them directly without string parsing.
No dependency data recorded yet.