enable gzip on Plug.Static unconditionally
Plug.Static with gzip: true serves .gz files when they exist (created by phx.digest) and falls back to uncompressed otherwise. The previous code_reloading? guard was needlessly conservative — in dev without digested assets, there are no .gz files so nothing changes. With the lighthouse task building prod assets, this gives realistic transfer sizes (42KB JS vs 135KB). Mobile lighthouse scores jump from 95-97 to 99-100. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
516d0d0070
commit
1f4e938ed1
@ -16,18 +16,12 @@ defmodule SimpleshopThemeWeb.Endpoint do
|
||||
longpoll: [connect_info: [session: @session_options]]
|
||||
|
||||
# Serve at "/" the static files from "priv/static" directory.
|
||||
#
|
||||
# When code reloading is disabled (e.g., in production),
|
||||
# the `gzip` option is enabled to serve compressed
|
||||
# static files generated by running `phx.digest`.
|
||||
#
|
||||
# Cache headers: 1 year for all static assets. Digested assets (with hash
|
||||
# in filename) use `immutable`. Fonts/mockups/images rarely change and
|
||||
# benefit from aggressive caching.
|
||||
# gzip is always enabled — Plug.Static serves .gz files when they exist
|
||||
# (created by `mix phx.digest`), falls back to uncompressed otherwise.
|
||||
plug Plug.Static,
|
||||
at: "/",
|
||||
from: :simpleshop_theme,
|
||||
gzip: not code_reloading?,
|
||||
gzip: true,
|
||||
only: SimpleshopThemeWeb.static_paths(),
|
||||
cache_control_for_etags: "public, max-age=31536000, immutable"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user