Add a NoCache setting

Added this to the settings so it can be configured at runtime.  If set
to true, a Cache-Control header will be sent with the wasm file as well
as the index html.
This commit is contained in:
Zorchenhimer 2019-03-30 14:21:46 -04:00
parent 237619f57e
commit 0a817eff87
2 changed files with 9 additions and 2 deletions

View File

@ -63,7 +63,9 @@ func wsStaticFiles(w http.ResponseWriter, r *http.Request) {
}
func wsWasmFile(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-cache, must-revalidate")
if settings.NoCache {
w.Header().Set("Cache-Control", "no-cache, must-revalidate")
}
http.ServeFile(w, r, "./static/main.wasm")
}
@ -215,7 +217,9 @@ func handleIndexTemplate(w http.ResponseWriter, r *http.Request) {
}
// Force browser to replace cache since file was not changed
w.Header().Set("Cache-Control", "no-cache, must-revalidate")
if settings.NoCache {
w.Header().Set("Cache-Control", "no-cache, must-revalidate")
}
err = t.Execute(w, data)
if err != nil {

View File

@ -32,6 +32,9 @@ type Settings struct {
Bans []BanInfo
LogLevel common.LogLevel
LogFile string
// Send the NoCache header?
NoCache bool
}
type BanInfo struct {