some more consistency with cache control that's drifted over time

This commit is contained in:
Ted Unangst 2019-10-23 17:58:45 -04:00
parent 87e78c33ba
commit 15f3beae6a
1 changed files with 9 additions and 6 deletions

15
web.go
View File

@ -760,9 +760,6 @@ func honkpage(w http.ResponseWriter, u *login.UserInfo, honks []*Honk, templinfo
if u != nil { if u != nil {
userid = u.UserID userid = u.UserID
} }
if u == nil {
w.Header().Set("Cache-Control", "max-age=60")
}
reverbolate(userid, honks) reverbolate(userid, honks)
templinfo["Honks"] = honks templinfo["Honks"] = honks
if templinfo["TopHID"] == nil { if templinfo["TopHID"] == nil {
@ -772,6 +769,9 @@ func honkpage(w http.ResponseWriter, u *login.UserInfo, honks []*Honk, templinfo
templinfo["TopHID"] = 0 templinfo["TopHID"] = 0
} }
} }
if u == nil {
w.Header().Set("Cache-Control", "max-age=60")
}
err := readviews.Execute(w, "honkpage.html", templinfo) err := readviews.Execute(w, "honkpage.html", templinfo)
if err != nil { if err != nil {
log.Print(err) log.Print(err)
@ -1548,7 +1548,6 @@ func fingerlicker(w http.ResponseWriter, r *http.Request) {
l["href"] = user.URL l["href"] = user.URL
j["links"] = []junk.Junk{l} j["links"] = []junk.Junk{l}
w.Header().Set("Cache-Control", "max-age=3600")
w.Header().Set("Content-Type", "application/jrd+json") w.Header().Set("Content-Type", "application/jrd+json")
j.Write(w) j.Write(w)
} }
@ -1572,7 +1571,7 @@ func servecss(w http.ResponseWriter, r *http.Request) {
return return
} }
defer fd.Close() defer fd.Close()
w.Header().Set("Cache-Control", "max-age=0") w.Header().Set("Cache-Control", "max-age=7776000")
w.Header().Set("Content-Type", "text/css; charset=utf-8") w.Header().Set("Content-Type", "text/css; charset=utf-8")
err = css.Filter(fd, w) err = css.Filter(fd, w)
if err != nil { if err != nil {
@ -1585,13 +1584,17 @@ func serveasset(w http.ResponseWriter, r *http.Request) {
} }
func servehelp(w http.ResponseWriter, r *http.Request) { func servehelp(w http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["name"] name := mux.Vars(r)["name"]
w.Header().Set("Cache-Control", "max-age=600") w.Header().Set("Cache-Control", "max-age=3600")
http.ServeFile(w, r, "docs/"+name) http.ServeFile(w, r, "docs/"+name)
} }
func servehtml(w http.ResponseWriter, r *http.Request) { func servehtml(w http.ResponseWriter, r *http.Request) {
u := login.GetUserInfo(r)
templinfo := getInfo(r) templinfo := getInfo(r)
templinfo["AboutMsg"] = aboutMsg templinfo["AboutMsg"] = aboutMsg
templinfo["LoginMsg"] = loginMsg templinfo["LoginMsg"] = loginMsg
if u == nil {
w.Header().Set("Cache-Control", "max-age=60")
}
err := readviews.Execute(w, r.URL.Path[1:]+".html", templinfo) err := readviews.Execute(w, r.URL.Path[1:]+".html", templinfo)
if err != nil { if err != nil {
log.Print(err) log.Print(err)