// 单个缓存条件设置 Vue.component("http-cache-ref-box", { props: ["v-cache-ref", "v-is-reverse"], mounted: function () { this.$refs.variablesDescriber.update(this.ref.key) if (this.ref.simpleCond != null) { this.condType = this.ref.simpleCond.type this.changeCondType(this.ref.simpleCond.type, true) this.condCategory = "simple" } else if (this.ref.conds != null && this.ref.conds.groups != null) { this.condCategory = "complex" } this.changeCondCategory(this.condCategory) }, data: function () { let ref = this.vCacheRef if (ref == null) { ref = { isOn: true, cachePolicyId: 0, key: "${scheme}://${host}${requestPath}${isArgs}${args}", life: {count: 1, unit: "day"}, status: [200], maxSize: {count: 128, unit: "mb"}, minSize: {count: 0, unit: "kb"}, skipCacheControlValues: ["private", "no-cache", "no-store"], skipSetCookie: true, enableRequestCachePragma: false, conds: null, // 复杂条件 simpleCond: null, // 简单条件 allowChunkedEncoding: true, allowPartialContent: true, forcePartialContent: false, enableIfNoneMatch: false, enableIfModifiedSince: false, enableReadingOriginAsync: false, isReverse: this.vIsReverse, methods: [], expiresTime: { isPrior: false, isOn: false, overwrite: true, autoCalculate: true, duration: {count: -1, "unit": "hour"} } } } if (ref.key == null) { ref.key = "" } if (ref.methods == null) { ref.methods = [] } if (ref.life == null) { ref.life = {count: 2, unit: "hour"} } if (ref.maxSize == null) { ref.maxSize = {count: 32, unit: "mb"} } if (ref.minSize == null) { ref.minSize = {count: 0, unit: "kb"} } let condType = "url-extension" let condComponent = window.REQUEST_COND_COMPONENTS.$find(function (k, v) { return v.type == "url-extension" }) return { ref: ref, keyIgnoreArgs: typeof ref.key == "string" && ref.key.indexOf("${args}") < 0, moreOptionsVisible: false, condCategory: "simple", // 条件分类:simple|complex condType: condType, condComponent: condComponent, condIsCaseInsensitive: (ref.simpleCond != null) ? ref.simpleCond.isCaseInsensitive : true, components: window.REQUEST_COND_COMPONENTS } }, watch: { keyIgnoreArgs: function (b) { if (typeof this.ref.key != "string") { return } if (b) { this.ref.key = this.ref.key.replace("${isArgs}${args}", "") return; } if (this.ref.key.indexOf("${isArgs}") < 0) { this.ref.key = this.ref.key + "${isArgs}" } if (this.ref.key.indexOf("${args}") < 0) { this.ref.key = this.ref.key + "${args}" } } }, methods: { changeOptionsVisible: function (v) { this.moreOptionsVisible = v }, changeLife: function (v) { this.ref.life = v }, changeMaxSize: function (v) { this.ref.maxSize = v }, changeMinSize: function (v) { this.ref.minSize = v }, changeConds: function (v) { this.ref.conds = v this.ref.simpleCond = null }, changeStatusList: function (list) { let result = [] list.forEach(function (status) { let statusNumber = parseInt(status) if (isNaN(statusNumber) || statusNumber < 100 || statusNumber > 999) { return } result.push(statusNumber) }) this.ref.status = result }, changeMethods: function (methods) { this.ref.methods = methods.map(function (v) { return v.toUpperCase() }) }, changeKey: function (key) { this.$refs.variablesDescriber.update(key) }, changeExpiresTime: function (expiresTime) { this.ref.expiresTime = expiresTime }, // 切换条件类型 changeCondCategory: function (condCategory) { this.condCategory = condCategory // resize window let dialog = window.parent.document.querySelector("*[role='dialog']") if (dialog == null) { return } switch (condCategory) { case "simple": dialog.style.width = "45em" break case "complex": let width = window.parent.innerWidth if (width > 1024) { width = 1024 } dialog.style.width = width + "px" if (this.ref.conds != null) { this.ref.conds.isOn = true } break } }, changeCondType: function (condType, isInit) { if (!isInit && this.ref.simpleCond != null) { this.ref.simpleCond.value = null } let def = this.components.$find(function (k, component) { return component.type == condType }) if (def != null) { this.condComponent = def } } }, template: `
选中后表示对比时忽略参数值的大小写。
选中后,表示缓存Key中不包含URI参数(即问号(?))后面的内容。
用来区分不同缓存内容的唯一Key。
允许请求的缓存方法,默认支持所有的请求方法。
内容尺寸如果高于此值则不缓存。
内容尺寸如果低于此值则不缓存。
选中后,支持缓存源站返回的某个分片的内容,该内容通过
选中后,表示无论客户端是否发送
选中后,表示把所有包含Range报头的请求都转发到源站,而不是尝试从缓存中读取。
允许缓存的HTTP状态码列表。
当响应的Cache-Control为这些值时不缓存响应内容,而且不区分大小写。
选中后,当响应的报头中有Set-Cookie时不缓存响应内容,防止动态内容被缓存。
选中后,当请求的报头中含有Pragma: no-cache或Cache-Control: no-cache时,会跳过缓存直接读取源内容,一般仅用于调试。
特殊情况下才需要开启,可能会降低缓存命中率。
特殊情况下才需要开启,可能会降低缓存命中率。
试验功能。允许客户端中断连接后,仍然继续尝试从源站读取内容并缓存。
选中后,Gzip等压缩后的Chunked内容可以直接缓存,无需检查内容长度。