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中增加 |
| 添加Age Header |
选中后自动在响应Header中增加 |
| 允许PURGE |
允许使用PURGE方法清除某个URL缓存。 |
| PURGE Key * |
[随机生成]。需要在PURGE方法调用时加入 |