Vue.component("http-cache-config-box", { props: ["v-cache-config", "v-is-location", "v-is-group", "v-cache-policy", "v-web-id"], data: function () { let cacheConfig = this.vCacheConfig if (cacheConfig == null) { cacheConfig = { isPrior: false, isOn: false, addStatusHeader: true, addAgeHeader: false, enableCacheControlMaxAge: false, cacheRefs: [], purgeIsOn: false, purgeKey: "", disablePolicyRefs: false } } if (cacheConfig.cacheRefs == null) { cacheConfig.cacheRefs = [] } let maxBytes = null if (this.vCachePolicy != null && this.vCachePolicy.maxBytes != null) { maxBytes = this.vCachePolicy.maxBytes } // key if (cacheConfig.key == null) { // use Vue.set to activate vue events Vue.set(cacheConfig, "key", { isOn: false, scheme: "https", host: "" }) } return { cacheConfig: cacheConfig, moreOptionsVisible: false, enablePolicyRefs: !cacheConfig.disablePolicyRefs, maxBytes: maxBytes, searchBoxVisible: false, searchKeyword: "", keyOptionsVisible: false } }, watch: { enablePolicyRefs: function (v) { this.cacheConfig.disablePolicyRefs = !v }, searchKeyword: function (v) { this.$refs.cacheRefsConfigBoxRef.search(v) } }, methods: { isOn: function () { return ((!this.vIsLocation && !this.vIsGroup) || this.cacheConfig.isPrior) && this.cacheConfig.isOn }, isPlus: function () { return Tea.Vue.teaIsPlus }, generatePurgeKey: function () { let r = Math.random().toString() + Math.random().toString() let s = r.replace(/0\./g, "") .replace(/\./g, "") let result = "" for (let i = 0; i < s.length; i++) { result += String.fromCharCode(parseInt(s.substring(i, i + 1)) + ((Math.random() < 0.5) ? "a" : "A").charCodeAt(0)) } this.cacheConfig.purgeKey = result }, showMoreOptions: function () { this.moreOptionsVisible = !this.moreOptionsVisible }, changeStale: function (stale) { this.cacheConfig.stale = stale }, showSearchBox: function () { this.searchBoxVisible = !this.searchBoxVisible if (this.searchBoxVisible) { let that = this setTimeout(function () { that.$refs.searchBox.focus() }) } else { this.searchKeyword = "" } } }, template: `
全局缓存策略
{{vCachePolicy.name}}

使用当前网站所在集群的设置。

当前集群没有设置缓存策略,当前配置无法生效。
启用缓存
缓存主域名
默认   [修改]
使用主域名:{{cacheConfig.key.scheme}}://{{cacheConfig.key.host}}   [修改]
启用主域名

启用主域名后,所有缓存键值中的协议和域名部分都会修改为主域名,用来实现缓存不区分域名。

主域名 *

此域名必须是当前网站已绑定域名,在刷新缓存时也需要使用此域名。

收起选项更多选项
使用默认缓存条件

选中后使用系统全局缓存策略中已经定义的默认缓存条件。

添加X-Cache报头

选中后自动在响应报头中增加X-Cache: BYPASS|MISS|HIT|PURGE;在浏览器端查看X-Cache值时请先禁用浏览器缓存,避免影响观察。

添加Age Header

选中后自动在响应Header中增加Age: [存活时间秒数]

支持源站控制有效时间

选中后表示支持源站在Header中设置的Cache-Control: max-age=[有效时间秒数]

允许PURGE

允许使用PURGE方法清除某个URL缓存。

PURGE Key *

[随机生成]。需要在PURGE方法调用时加入X-Edge-Purge-Key: {{cacheConfig.purgeKey}} Header。只能包含字符、数字、下划线。

过时缓存策略

缓存条件   [添加]   [搜索]

` })