mirror of
https://github.com/Noooste/garage-ui.git
synced 2026-08-18 09:03:13 +00:00
fix(backend): improve cache control headers for static file serving
Signed-off-by: Noste <83548733+Noooste@users.noreply.github.com>
This commit is contained in:
@@ -355,10 +355,15 @@ func SetupRoutes(
|
||||
// Try to serve static files first
|
||||
filePath := filepath.Join(cfg.Server.FrontendPath, path)
|
||||
if info, err := os.Stat(filePath); err == nil && !info.IsDir() {
|
||||
if strings.HasPrefix(path, "/assets/") {
|
||||
c.Set(fiber.HeaderCacheControl, "public, max-age=31536000, immutable")
|
||||
} else {
|
||||
c.Set(fiber.HeaderCacheControl, "no-cache")
|
||||
}
|
||||
return c.SendFile(filePath)
|
||||
}
|
||||
|
||||
// If no static file exists, serve index.html for SPA routing
|
||||
c.Set(fiber.HeaderCacheControl, "no-cache")
|
||||
indexPath := filepath.Join(cfg.Server.FrontendPath, "index.html")
|
||||
return c.SendFile(indexPath)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user