Go · 684 bytes Raw Blame History
1 // SPDX-License-Identifier: AGPL-3.0-or-later
2
3 package handlers
4
5 import (
6 "io/fs"
7 "net/http"
8 )
9
10 // staticFileServer serves files from the embedded static FS with sane
11 // caching headers. S02 will replace this with a content-hashed asset
12 // pipeline; S00 keeps the surface minimal.
13 func staticFileServer(staticFS fs.FS) http.Handler {
14 fileServer := http.FileServer(http.FS(staticFS))
15 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
16 // Conservative caching: short TTL + must-revalidate. Long-cache
17 // behavior moves to fingerprinted URLs in S02.
18 w.Header().Set("Cache-Control", "public, max-age=300, must-revalidate")
19 fileServer.ServeHTTP(w, r)
20 })
21 }
22