diff --git a/go.mod b/go.mod index 2fccee7f8..a65ba91d9 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,6 @@ require ( github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/puddle/v2 v2.2.3 // indirect github.com/kevinburke/ssh_config v1.6.0 // indirect - github.com/klauspost/compress v1.20.3 // indirect github.com/mattn/go-colorable v0.1.16 // indirect github.com/mattn/go-isatty v0.0.24 // indirect github.com/mfridman/interpolate v0.0.2 // indirect @@ -79,7 +78,6 @@ require ( github.com/go-git/go-billy/v6 v6.0.0-beta.1 github.com/go-git/go-git/v6 v6.0.0-beta.1 github.com/go-jose/go-jose/v4 v4.1.6 - github.com/go-telegram/bot v1.27.0 github.com/go-webauthn/webauthn v0.18.2 github.com/golang-jwt/jwt/v5 v5.3.1 github.com/google/jsonschema-go v0.4.3 @@ -87,6 +85,7 @@ require ( github.com/hashicorp/go-hclog v1.6.3 github.com/hashicorp/go-plugin v1.8.0 github.com/jackc/pgx/v5 v5.11.0 + github.com/klauspost/compress v1.20.3 github.com/moby/moby/api v1.56.1 github.com/moby/moby/client v0.6.2 github.com/modelcontextprotocol/go-sdk v1.8.0 diff --git a/go.sum b/go.sum index 1004af04d..dc5645d93 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,6 @@ github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-telegram/bot v1.27.0 h1:PG9yBDzM8O26oUerE9SZwWlHon4RpH8WcNslZ7CEZmE= -github.com/go-telegram/bot v1.27.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/go-webauthn/webauthn v0.18.2 h1:0BeftmEHU7i3Dv0VFwBtidy/ba37Vcdjvqst9EYu8Sk= diff --git a/internal/webui/server.go b/internal/webui/server.go index 5bc66a294..4108ed76f 100644 --- a/internal/webui/server.go +++ b/internal/webui/server.go @@ -12,6 +12,8 @@ import ( "sync" "time" + "github.com/klauspost/compress/gzhttp" + controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1" "github.com/samcharles93/archie-core/internal/domain/access" "github.com/samcharles93/archie-core/internal/domain/audit" @@ -412,7 +414,7 @@ func (s *Server) assets() http.Handler { }) } files := http.FileServerFS(ui.DistDirFS) - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + return gzhttp.GzipHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if strings.HasPrefix(r.URL.Path, "/api/") { http.Error(w, "this archied does not serve "+r.URL.Path, http.StatusNotFound) return @@ -421,8 +423,15 @@ func (s *Server) assets() http.Handler { r = r.Clone(r.Context()) r.URL.Path = "/" } + // Asset names carry a content hash, so a cached copy never goes stale; + // index.html names the current hashes and must always be revalidated. + if strings.HasPrefix(r.URL.Path, "/assets/") { + w.Header().Set("Cache-Control", "public, max-age=31536000, immutable") + } else { + w.Header().Set("Cache-Control", "no-cache") + } files.ServeHTTP(w, r) - }) + })) } func trimLeadingSlash(p string) string { diff --git a/ui/vite.config.ts b/ui/vite.config.ts index 57c2b198b..318e03576 100644 --- a/ui/vite.config.ts +++ b/ui/vite.config.ts @@ -13,13 +13,6 @@ export default defineConfig({ build: { outDir: "dist", emptyOutDir: true, - rollupOptions: { - output: { - entryFileNames: "assets/[name].js", - chunkFileNames: "assets/[name].js", - assetFileNames: "assets/[name].[ext]", - }, - }, }, server: { // Proxies the API to a locally running archie-ui (the process that serves