UNPKG

node-web-mvc

Version:
52 lines (51 loc) 1.47 kB
"use strict"; /** * @module CacheControl * @description http缓存控制 */ Object.defineProperty(exports, "__esModule", { value: true }); class CacheControl { constructor(options) { this.maxAge = options.maxAge; this.sMaxAge = options.sMaxAge; this.mustRevalidate = options.mustRevalidate; this.noTransform = options.noTransform; this.noStore = options.noStore; this.noCache = options.noCache; this.proxyRevalidate = options.proxyRevalidate; this.isPublic = options.isPublic; this.isPrivate = options.isPrivate; } toString() { const values = []; if (this.maxAge >= 0) { values.push(`max-age=${this.maxAge}`); } if (this.noCache) { values.push('no-cache'); } if (this.noStore) { values.push('no-store'); } if (this.mustRevalidate) { values.push('must-revalidate'); } if (this.noTransform) { values.push('no-transform'); } if (this.isPublic) { values.push('public'); } if (this.isPrivate) { values.push('private'); } if (this.proxyRevalidate) { values.push('proxy-revalidate'); } if (this.sMaxAge != null) { values.push(`s-maxage=${this.sMaxAge}`); } return values.join(','); } } exports.default = CacheControl;