mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-05 22:30:28 +08:00
缓存设置中增加自动添加X-Cache Header
This commit is contained in:
@@ -60,13 +60,17 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
// 日志
|
// 日志
|
||||||
defer this.CreateLog(oplogs.LevelInfo, "修改Web %d 的缓存设置", params.WebId)
|
defer this.CreateLog(oplogs.LevelInfo, "修改Web %d 的缓存设置", params.WebId)
|
||||||
|
|
||||||
// TODO 校验配置
|
// 校验配置
|
||||||
cacheConfig := &serverconfigs.HTTPCacheConfig{}
|
cacheConfig := &serverconfigs.HTTPCacheConfig{}
|
||||||
err := json.Unmarshal(params.CacheJSON, cacheConfig)
|
err := json.Unmarshal(params.CacheJSON, cacheConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
err = cacheConfig.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("检查配置失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// 去除不必要的部分
|
// 去除不必要的部分
|
||||||
for _, cacheRef := range cacheConfig.CacheRefs {
|
for _, cacheRef := range cacheConfig.CacheRefs {
|
||||||
|
|||||||
@@ -57,13 +57,17 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
}) {
|
}) {
|
||||||
defer this.CreateLogInfo("修改Web %d 的缓存设置", params.WebId)
|
defer this.CreateLogInfo("修改Web %d 的缓存设置", params.WebId)
|
||||||
|
|
||||||
// TODO 校验配置
|
// 校验配置
|
||||||
cacheConfig := &serverconfigs.HTTPCacheConfig{}
|
cacheConfig := &serverconfigs.HTTPCacheConfig{}
|
||||||
err := json.Unmarshal(params.CacheJSON, cacheConfig)
|
err := json.Unmarshal(params.CacheJSON, cacheConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
err = cacheConfig.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("检查配置失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// 去除不必要的部分
|
// 去除不必要的部分
|
||||||
for _, cacheRef := range cacheConfig.CacheRefs {
|
for _, cacheRef := range cacheConfig.CacheRefs {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ Vue.component("http-cache-config-box", {
|
|||||||
cacheConfig = {
|
cacheConfig = {
|
||||||
isPrior: false,
|
isPrior: false,
|
||||||
isOn: false,
|
isOn: false,
|
||||||
|
addStatusHeader: true,
|
||||||
cacheRefs: []
|
cacheRefs: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,13 +106,22 @@ Vue.component("http-cache-config-box", {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<tbody v-show="isOn()">
|
||||||
|
<tr>
|
||||||
|
<td>自动添加X-Cache Header</td>
|
||||||
|
<td>
|
||||||
|
<checkbox v-model="cacheConfig.addStatusHeader"></checkbox>
|
||||||
|
<p class="comment">选中后自动在响应Header中增加<code-label>X-Cache: BYPASS|MISS|HIT</code-label>。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div v-show="isOn()">
|
<div v-show="isOn()">
|
||||||
<table class="ui table selectable celled" v-show="cacheConfig.cacheRefs.length > 0">
|
<table class="ui table selectable celled" v-show="cacheConfig.cacheRefs.length > 0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>条件</th>
|
<th>缓存条件</th>
|
||||||
<th class="width10">缓存时间</th>
|
<th class="width10">缓存时间</th>
|
||||||
<th class="two op">操作</th>
|
<th class="two op">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user