{"library":"pretty-cache-header","title":"Pretty Cache Header Utility","description":"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.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install pretty-cache-header"],"cli":null},"imports":["import { cacheHeader } from 'pretty-cache-header';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { cacheHeader } from 'pretty-cache-header';\n\nfunction createResponseWithCaching() {\n  const cacheControlHeader = cacheHeader({\n    public: true,\n    maxAge: '1week',\n    sMaxage: '1hour',\n    staleWhileRevalidate: '1year',\n    immutable: true\n  });\n\n  // In a real application, this would be part of an HTTP response.\n  // For demonstration, we'll just log the header value.\n  console.log('Generated Cache-Control Header:', cacheControlHeader);\n\n  // Example of how it might be used in a web framework (e.g., Express.js or a Web Fetch API response)\n  // return new Response('Content', {\n  //   headers: {\n  //     'Content-Type': 'text/plain',\n  //     'Cache-Control': cacheControlHeader\n  //   }\n  // });\n  return cacheControlHeader;\n}\n\ncreateResponseWithCaching();","lang":"typescript","description":"Demonstrates how to import and use `cacheHeader` to generate a `Cache-Control` string with human-readable time values and common directives.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}