the 304 logic doesn't always work? just remove it.
only need to load servermsg once, btw.
This commit is contained in:
parent
c925160853
commit
c6d50c9cfd
21
honk.go
21
honk.go
|
@ -93,6 +93,7 @@ type Honker struct {
|
||||||
|
|
||||||
var serverName string
|
var serverName string
|
||||||
var iconName = "icon.png"
|
var iconName = "icon.png"
|
||||||
|
var serverMsg = "Things happen."
|
||||||
|
|
||||||
var readviews *templates.Template
|
var readviews *templates.Template
|
||||||
|
|
||||||
|
@ -122,33 +123,16 @@ func homepage(w http.ResponseWriter, r *http.Request) {
|
||||||
honks = getpublichonks()
|
honks = getpublichonks()
|
||||||
}
|
}
|
||||||
|
|
||||||
var modtime time.Time
|
|
||||||
if len(honks) > 0 {
|
|
||||||
modtime = honks[0].Date
|
|
||||||
}
|
|
||||||
debug := false
|
|
||||||
getconfig("debug", &debug)
|
|
||||||
imh := r.Header.Get("If-Modified-Since")
|
|
||||||
if !debug && imh != "" && !modtime.IsZero() {
|
|
||||||
ifmod, err := time.Parse(http.TimeFormat, imh)
|
|
||||||
if err == nil && !modtime.After(ifmod) {
|
|
||||||
w.WriteHeader(http.StatusNotModified)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reverbolate(honks)
|
reverbolate(honks)
|
||||||
|
|
||||||
msg := "Things happen."
|
|
||||||
getconfig("servermsg", &msg)
|
|
||||||
templinfo["Honks"] = honks
|
templinfo["Honks"] = honks
|
||||||
templinfo["ShowRSS"] = true
|
templinfo["ShowRSS"] = true
|
||||||
templinfo["ServerMessage"] = msg
|
templinfo["ServerMessage"] = serverMsg
|
||||||
if u == nil {
|
if u == nil {
|
||||||
w.Header().Set("Cache-Control", "max-age=60")
|
w.Header().Set("Cache-Control", "max-age=60")
|
||||||
} else {
|
} else {
|
||||||
w.Header().Set("Cache-Control", "max-age=0")
|
w.Header().Set("Cache-Control", "max-age=0")
|
||||||
}
|
}
|
||||||
w.Header().Set("Last-Modified", modtime.Format(http.TimeFormat))
|
|
||||||
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)
|
||||||
|
@ -1475,6 +1459,7 @@ func main() {
|
||||||
if dbversion != myVersion {
|
if dbversion != myVersion {
|
||||||
log.Fatal("incorrect database version. run upgrade.")
|
log.Fatal("incorrect database version. run upgrade.")
|
||||||
}
|
}
|
||||||
|
getconfig("servermsg", &serverMsg)
|
||||||
getconfig("servername", &serverName)
|
getconfig("servername", &serverName)
|
||||||
prepareStatements(db)
|
prepareStatements(db)
|
||||||
switch cmd {
|
switch cmd {
|
||||||
|
|
Loading…
Reference in New Issue