From 086b83761137559e2a3fbcd2ad7cd439221890bb Mon Sep 17 00:00:00 2001 From: Rico Moorman Date: Tue, 26 Nov 2024 17:55:43 +0100 Subject: [PATCH] Set gzip default based on code reloading in endpoint (#5972) Adjust the default for the gzip flag in the generated endpoint to take code reloading into account. Fixes phoenixframework/phoenix#5960 --- installer/templates/phx_web/endpoint.ex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/installer/templates/phx_web/endpoint.ex b/installer/templates/phx_web/endpoint.ex index f14b4d97b0..4b37bf5bcf 100644 --- a/installer/templates/phx_web/endpoint.ex +++ b/installer/templates/phx_web/endpoint.ex @@ -17,12 +17,13 @@ defmodule <%= @endpoint_module %> do # Serve at "/" the static files from "priv/static" directory. # - # You should set gzip to true if you are running phx.digest - # when deploying your static files in production. + # When code reloading is disabled (e.g., in production), + # the `gzip` option is enabled to serve compressed + # static files generated by running `phx.digest`. plug Plug.Static, at: "/", from: :<%= @web_app_name %>, - gzip: false, + gzip: not code_reloading?, only: <%= @web_namespace %>.static_paths() # Code reloading can be explicitly enabled under the