feat: 推广 V3.5 实时氢耗并完善导出
This commit is contained in:
@@ -19,9 +19,21 @@ func Handler(dir string, fallback http.Handler) http.Handler {
|
||||
}
|
||||
path := filepath.Join(dir, filepath.Clean(r.URL.Path))
|
||||
if info, err := os.Stat(path); err == nil && !info.IsDir() {
|
||||
setCachePolicy(w, r.URL.Path)
|
||||
fs.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
http.ServeFile(w, r, filepath.Join(dir, "index.html"))
|
||||
})
|
||||
}
|
||||
|
||||
func setCachePolicy(w http.ResponseWriter, path string) {
|
||||
if path == "/" || path == "/index.html" || path == "/app-config.js" {
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(path, "/assets/") {
|
||||
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user