Skip to content

Commit b2d2677

Browse files
committed
移除API缓存
1 parent f162ab3 commit b2d2677

File tree

5 files changed

+0
-24
lines changed

5 files changed

+0
-24
lines changed

change.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
- [x] 私有项目,增加访问密码(项目成员可以免密码访问)
4242
- [x] 小分辨率电脑,内容阅读时,不悬浮显示内容菜单,避免影响阅读体验
4343
- [x] 配置管理,增加图片链接由`http://`自动替换为`https://`开关,因为 --> [Chrome 将不再允许 https:// 页面加载 HTTP 资源](https://www.oschina.net/news/110345/chrome-to-block-http-in-https)
44-
- [x] 使用`Cache-Control`实现API缓存设置
4544
- [x] 如果只有作者才能写作,则如果项目创建者不是作者,已创建了项目的,不允许私有转公有、不允许私密分享
4645
- [x] 项目成员PC端无法访问和编辑项目的问题处理
4746
- [x] 管理员和创始人可以设置书籍信息以及生成电子书

controllers/api/BaseController.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ func (this *BaseController) Response(httpStatus int, message string, data ...int
167167
beego.Error(err)
168168
}
169169

170-
if this.Ctx.Request.Method == http.MethodGet && models.GetHTTPCache() > 0 {
171-
this.Ctx.ResponseWriter.Header().Set("Cache-Control", fmt.Sprintf("max-age=%v", models.GetHTTPCache()))
172-
}
173-
174170
this.Ctx.ResponseWriter.Header().Set("Content-Type", "application/json; charset=utf-8")
175171
if strings.Contains(strings.ToLower(this.Ctx.Request.Header.Get("Accept-Encoding")), "gzip") { //gzip压缩
176172
this.Ctx.ResponseWriter.Header().Set("Content-Encoding", "gzip")

models/base.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,8 @@ import (
1616
"github.com/astaxie/beego/orm"
1717
)
1818

19-
var httpCache = 0
20-
2119
func Init() {
2220
initAPI()
23-
go func() {
24-
httpCache, _ = strconv.Atoi(GetOptionValue("HTTP_CACHE", "0"))
25-
time.Sleep(60 * time.Second)
26-
}()
27-
}
28-
29-
func GetHTTPCache() int {
30-
return httpCache
3121
}
3222

3323
//设置增减

models/options.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ func (m *Option) Init() error {
206206
OptionValue: "false",
207207
OptionName: "AUTO_HTTPS",
208208
OptionTitle: "图片链接HTTP转HTTPS",
209-
}, {
210-
OptionValue: "30",
211-
OptionName: "HTTP_CACHE",
212-
OptionTitle: "是否开启API缓存",
213209
},
214210
}
215211

views/manager/setting.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@
195195
<input type="text" name="DOWNLOAD_LIMIT" class="form-control" value="{{.DOWNLOAD_LIMIT.OptionValue}}">
196196
</div>
197197

198-
<div class="form-group">
199-
<label>HTTP缓存( <span class="text-muted">针对小程序/移动APP的API。0表示不缓存,大于0表示缓存多少秒,默认30,即缓存30秒</span> )</label>
200-
<input type="number" min="0" name="HTTP_CACHE" class="form-control" value="{{.HTTP_CACHE.OptionValue}}">
201-
</div>
202-
203198
<div class="form-group">
204199
<label>{{.AUTO_HTTPS.OptionTitle}} ( <span class="text-muted">将图片链接由 http:// 自动替换为 https:// </span>)</label>
205200
<div class="radio">

0 commit comments

Comments
 (0)