Vue.component("http-cache-config-box", { props: ["v-cache-config", "v-is-location", "v-is-group", "v-cache-policy"], data: function () { let cacheConfig = this.vCacheConfig if (cacheConfig == null) { cacheConfig = { isPrior: false, isOn: false, addStatusHeader: true, addAgeHeader: false, cacheRefs: [], purgeIsOn: false, purgeKey: "" } } if (cacheConfig.cacheRefs == null) { cacheConfig.cacheRefs = [] } return { cacheConfig: cacheConfig, moreOptionsVisible: false } }, methods: { isOn: function () { return ((!this.vIsLocation && !this.vIsGroup) || this.cacheConfig.isPrior) && this.cacheConfig.isOn }, 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 } }, template: `
缓存策略
{{vCachePolicy.name}}

使用当前服务所在集群的设置。

当前集群没有设置缓存策略,当前配置无法生效。
是否开启缓存
收起选项更多选项
添加X-Cache Header

选中后自动在响应Header中增加X-Cache: BYPASS|MISS|HIT|PURGE

添加Age Header

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

允许PURGE

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

PURGE Key *

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

缓存条件

` })