From bd2521b14b20968d463039866f64c20bb22f370b Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Fri, 21 Apr 2023 01:19:57 +0300 Subject: [PATCH] added cache-control header for the admin ui assets --- CHANGELOG.md | 6 ++++-- apis/base.go | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42afec61..ae4199bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ -## (WIP) v0.15.1 +## v0.15.1 + +- Trigger the related `Record` model realtime subscription events on [custom model struct](https://pocketbase.io/docs/custom-models/) save ([#2325](https://github.com/pocketbase/pocketbase/discussions/2325)). - Fixed `Ctrl + S` in the `editor` field not propagating the quick save shortcut to the parent form. @@ -8,7 +10,7 @@ - Reduced the record form vertical layout shifts and slightly improved the rendering speed when loading multiple `relation` fields. -- Trigger the related `Record` model realtime subscription events on [custom model struct](https://pocketbase.io/docs/custom-models/) save ([#2325](https://github.com/pocketbase/pocketbase/discussions/2325)). +- Enabled Admin UI assets cache. ## v0.15.0 diff --git a/apis/base.go b/apis/base.go index 0c607b6d..6336a878 100644 --- a/apis/base.go +++ b/apis/base.go @@ -180,6 +180,7 @@ func bindStaticAdminUI(app core.App, e *echo.Echo) error { trailedAdminPath+"*", echo.StaticDirectoryHandler(ui.DistDirFS, false), installerRedirect(app), + uiCacheControl(), middleware.Gzip(), ) @@ -199,6 +200,16 @@ func updateTotalAdminsCache(app core.App) error { return nil } +func uiCacheControl() echo.MiddlewareFunc { + return func(next echo.HandlerFunc) echo.HandlerFunc { + return func(c echo.Context) error { + c.Response().Header().Set("Cache-Control", "max-age=1209600, stale-while-revalidate=86400") + + return next(c) + } + } +} + // installerRedirect redirects the user to the installer admin UI page // when the application needs some preliminary configurations to be done. func installerRedirect(app core.App) echo.MiddlewareFunc {