Better HTTP caching

This commit is contained in:
NI
2019-08-27 15:43:38 +08:00
parent 526fe55d91
commit 6cfc5b0e07
5 changed files with 23 additions and 49 deletions

View File

@@ -76,20 +76,19 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case "/socket":
err = serveController(h.socketCtl, w, r, clientLogger)
case "/robots.txt":
case "/index.html":
fallthrough
case "/favicon.ico":
fallthrough
case "/README.md":
fallthrough
case "/LICENSE.md":
fallthrough
case "/DEPENDENCIES.md":
err = serveStaticData(r.URL.Path[1:], w, r, clientLogger)
case "/error.html":
err = ErrNotFound
default:
if strings.HasPrefix(r.URL.Path, "/assets/") {
err = serveStaticData(r.URL.Path[8:], w, r, clientLogger)
if len(r.URL.Path) > 0 {
err = serveStaticData(
r.URL.Path[1:],
staticFileExt(r.URL.Path[1:]),
w,
r,
clientLogger)
} else {
err = ErrNotFound
}