diff options
author | lain <lain@soykaf.club> | 2024-02-15 09:23:47 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2024-02-15 09:23:47 +0000 |
commit | f2f455f283a0508044adb5bf5aac0ec24116a24f (patch) | |
tree | c16d8a3577b75cd116dd9f4f154cae44dd56d7e0 | |
parent | f28dcc9cb748fc75d41cfc3038209fa45f2b90c7 (diff) | |
parent | 6b74a5527410c5e98a6c4906a8e6f9c4d9f5e5d1 (diff) | |
download | pleroma-f2f455f283a0508044adb5bf5aac0ec24116a24f.tar.gz pleroma-f2f455f283a0508044adb5bf5aac0ec24116a24f.zip |
Merge branch 'frontend-caching' into 'develop'
FrontendStatic should have reasonable caching
See merge request pleroma/pleroma!3685
-rw-r--r-- | lib/pleroma/web/endpoint.ex | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index 307fa069e..d93b04c0e 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -32,7 +32,8 @@ defmodule Pleroma.Web.Endpoint do plug(Pleroma.Web.Plugs.HTTPSecurityPlug) plug(Pleroma.Web.Plugs.UploadedMedia) - @static_cache_control "public, no-cache" + @static_cache_control "public, max-age=1209600" + @static_cache_disabled "public, no-cache" # InstanceStatic needs to be before Plug.Static to be able to override shipped-static files # If you're adding new paths to `only:` you'll need to configure them in InstanceStatic as well @@ -43,22 +44,32 @@ defmodule Pleroma.Web.Endpoint do from: :pleroma, only: ["emoji", "images"], gzip: true, - cache_control_for_etags: "public, max-age=1209600", + cache_control_for_etags: @static_cache_control, headers: %{ - "cache-control" => "public, max-age=1209600" + "cache-control" => @static_cache_control } ) plug(Pleroma.Web.Plugs.InstanceStatic, at: "/", gzip: true, - cache_control_for_etags: @static_cache_control, + cache_control_for_etags: @static_cache_disabled, headers: %{ - "cache-control" => @static_cache_control + "cache-control" => @static_cache_disabled + } + ) + + plug(Pleroma.Web.Plugs.FrontendStatic, + at: "/", + frontend_type: :primary, + only: ["index.html"], + gzip: true, + cache_control_for_etags: @static_cache_disabled, + headers: %{ + "cache-control" => @static_cache_disabled } ) - # Careful! No `only` restriction here, as we don't know what frontends contain. plug(Pleroma.Web.Plugs.FrontendStatic, at: "/", frontend_type: :primary, @@ -75,9 +86,9 @@ defmodule Pleroma.Web.Endpoint do at: "/pleroma/admin", frontend_type: :admin, gzip: true, - cache_control_for_etags: @static_cache_control, + cache_control_for_etags: @static_cache_disabled, headers: %{ - "cache-control" => @static_cache_control + "cache-control" => @static_cache_disabled } ) @@ -92,9 +103,9 @@ defmodule Pleroma.Web.Endpoint do only: Pleroma.Constants.static_only_files(), # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength gzip: true, - cache_control_for_etags: @static_cache_control, + cache_control_for_etags: @static_cache_disabled, headers: %{ - "cache-control" => @static_cache_control + "cache-control" => @static_cache_disabled } ) |