项目
在 GitHub 查看
jjenzz/pretty-cache-header
关于
一个 Cache-Control 响应头工具,可将易读的时间字符串解析为秒数。
其他项目实测星标增长
- 24小时
- 0
- 7天
- -1
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文pretty-cache-header
Cache-control header utility that parses human readable time strings into seconds.
Time based values use Template Literal Types to help avoid passing invalid time string formats.
Installation
npm i pretty-cache-header
Usage
import { cacheHeader } from 'pretty-cache-header';
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:
ms,milli,millisecond,milliseconds- will parse to millisecondss,sec,secs,second,seconds- will parse to secondsm,min,mins,minute,minutes- will parse to minutesh,hr,hrs,hour,hours- will parse to hoursd,day,days- will parse to daysw,week,weeks- will parse to weeksmon,mth,mths,month,months- will parse to monthsy,yr,yrs,year,years- will parse to years
探索相关项目
加载中…