feat: browser cache directives

This commit is contained in:
Ramires Viana committed 2021-04-19 12:49:40 +00:00
1 parent 603203848a
commit 190cb99a79
10 files changed
+41 -11

No files matched your search

+4
View File
@@ -2,6 +2,7 @@ package http
import (
"encoding/json"
"fmt"
"io/fs"
"log"
"net/http"
@@ -109,6 +110,9 @@ func getStaticHandlers(store *storage.Storage, server *settings.Server, assetsFs
return http.StatusNotFound, nil
}
const maxAge = 86400 // 1 day
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%v", maxAge))
if d.settings.Branding.Files != "" {
if strings.HasPrefix(r.URL.Path, "img/") {
fPath := filepath.Join(d.settings.Branding.Files, r.URL.Path)