Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 331a14e

Browse files
committed
fix: http expire time should be dynamic
1 parent 83360cb commit 331a14e

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

server/server_http.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ func (s *Server) webHandle(w http.ResponseWriter, r *http.Request) {
4848
return
4949
}
5050

51-
uptime := time.Unix(s.baseInfo.Uptime, 0)
52-
cacheSince := uptime.Format(http.TimeFormat)
53-
cacheExpire := uptime.AddDate(0, 1, 0).Format(http.TimeFormat) // 1 month expire date
54-
5551
pathDir := strings.SplitN(r.URL.Path[1:], "/", 2)
5652
switch pathDir[0] {
5753
case "search":
@@ -67,14 +63,12 @@ func (s *Server) webHandle(w http.ResponseWriter, r *http.Request) {
6763
case "download":
6864
s.dlfilesh.ServeHTTP(w, r)
6965
case s.baseInfo.Version:
70-
w.Header().Set("Last-Modified", cacheSince)
71-
w.Header().Set("Expires", cacheExpire)
66+
w.Header().Set("Expires", time.Now().UTC().AddDate(0, 6, 0).Format(http.TimeFormat))
7267
w.Header().Set("Cache-Control", "max-age:290304000, public")
7368
s.verStatich.ServeHTTP(w, r)
7469
default:
7570
//no match, assume static file
76-
w.Header().Set("Last-Modified", cacheSince)
77-
w.Header().Set("Expires", cacheExpire)
71+
w.Header().Set("Expires", time.Now().UTC().AddDate(0, 6, 0).Format(http.TimeFormat))
7872
w.Header().Set("Cache-Control", "max-age:290304000, public")
7973
s.statich.ServeHTTP(w, r)
8074
}

0 commit comments

Comments
 (0)