mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2025-10-28 16:55:32 +00:00
Cache Settings for DEV mode
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
package server
|
||||
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
import (
|
||||
"log/slog"
|
||||
"strings"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func CacheFunc(c *fiber.Ctx) bool {
|
||||
return c.Query("noCache") == "true" || c.Response().StatusCode() != fiber.StatusOK
|
||||
path := c.Path()
|
||||
// INFO: for now, css and js files are excluded from caching; they get cached via ETag to enable reloading on style changes.
|
||||
slog.Debug("CacheFunc:", "path", path)
|
||||
return c.Query("noCache") == "true" || c.Response().StatusCode() != fiber.StatusOK || strings.HasPrefix(path, "/assets")
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func New(engine *templating.Engine, storage fiber.Storage, debug bool) Server {
|
||||
server.Use(cache.New(cache.Config{
|
||||
Next: CacheFunc,
|
||||
Expiration: CACHE_TIME,
|
||||
CacheControl: true,
|
||||
CacheControl: false,
|
||||
Storage: storage,
|
||||
KeyGenerator: KeyGenerator,
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user