Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cache-header-string

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-header-string

Cache control header utility

  • 0.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

cache-header-string

Tiny cache control header utility that parses human readable time strings into seconds.

Time based values use Template Literal Types to avoid passing invalid time string formats.

Installation

npm install cache-header-string

Usage

return new Response(..., {
  headers: {
    // sets cache control header to "public, max-age=604800, stale-while-revalidate=31536000"
    'Cache-Control': cacheHeader({
      public: true,
      maxAge: '1week',
      staleWhileRevalidate: '1year'
    })
  }
})

TimeString format

Any number followed by a timestring keyword:

  1. ms, milli, millisecond, milliseconds - will parse to milliseconds
  2. s, sec, secs, second, seconds - will parse to seconds
  3. m, min, mins, minute, minutes - will parse to minutes
  4. h, hr, hrs, hour, hours - will parse to hours
  5. d, day, days - will parse to days
  6. w, week, weeks - will parse to weeks
  7. mon, mth, mths, month, months - will parse to months
  8. y, yr, yrs, year, years - will parse to years

FAQs

Package last updated on 02 Jan 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc