all repos — honk @ a8984000538dd76de12f4ea99eb4c5a0db7067c5

my fork of honk

reply with 304 if there's no new content to save some traffic
Ted Unangst tedu@tedunangst.com
Wed, 10 Apr 2019 19:25:32 -0400
commit

a8984000538dd76de12f4ea99eb4c5a0db7067c5

parent

c8ca98d7215103377fece36a71fdc45dfcf39902

1 files changed, 16 insertions(+), 0 deletions(-)

jump to
M honk.gohonk.go

@@ -172,11 +172,27 @@ sort.Slice(honks, func(i, j int) bool {

return honks[i].Date.After(honks[j].Date) }) reverbolate(honks) + + var modtime time.Time + if len(honks) > 0 { + modtime = honks[0].Date + } + imh := r.Header.Get("If-Modified-Since") + if imh != "" && !modtime.IsZero() { + ifmod, err := time.Parse(http.TimeFormat, imh) + if err == nil && !modtime.After(ifmod) { + w.WriteHeader(http.StatusNotModified) + return + } + } + msg := "Things happen." getconfig("servermsg", &msg) templinfo["Honks"] = honks templinfo["ShowRSS"] = true templinfo["ServerMessage"] = msg + w.Header().Set("Cache-Control", "max-age=0") + w.Header().Set("Last-Modified", modtime.Format(http.TimeFormat)) err := readviews.ExecuteTemplate(w, "homepage.html", templinfo) if err != nil { log.Print(err)