From 3be95a0aab0642073d6d610796baa5ea91b6ad84 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 14 Jul 2026 17:54:54 -0700 Subject: [PATCH 1/5] Build/Test Tools: Enable gzip compression in the local Docker environment. Add gzip directives to the nginx config template used by the local Docker environment so that HTML, JavaScript, CSS, JSON, XML, and SVG responses are served compressed. This matches the behavior of virtually all production WordPress hosts and makes front-end performance analysis against the local environment representative: without it, the site editor's ~8 MB of editor JavaScript is served uncompressed, so page-load metrics like LCP are dominated by transfer of dev assets that would be compressed in production. Compression only applies when the client sends `Accept-Encoding: gzip`, so existing uncompressed workflows are unaffected. `gzip_vary on` ensures caches key on the encoding. Co-Authored-By: Claude Opus 4.8 --- tools/local-env/default.template | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/local-env/default.template b/tools/local-env/default.template index 995913fb453a2..a2ff1d4882092 100644 --- a/tools/local-env/default.template +++ b/tools/local-env/default.template @@ -15,6 +15,21 @@ server { absolute_redirect off; + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 5; + gzip_min_length 256; + gzip_types + application/javascript + text/javascript + application/json + application/xml + application/rss+xml + text/css + text/plain + image/svg+xml; + if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$request_uri/ permanent; rewrite ^(/[^/]+)?(/wp-.*) $2 last; From 09ce87379a051e07bd025e180368239fef83589e Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 14 Jul 2026 18:52:08 -0700 Subject: [PATCH 2/5] Build/Test Tools: Make local environment text compression configurable. Add a `LOCAL_NGINX_COMPRESSION` option (valid values `on`/`off`, defaulting to `on`) that controls whether the web server serves compressed responses. The value is substituted into the nginx template the same way as `LOCAL_DIR`, so it can be set to `off` to reproduce uncompressed behavior for comparison. Co-Authored-By: Claude Opus 4.8 --- .env.example | 4 ++++ docker-compose.yml | 3 ++- tools/local-env/default.template | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 6974d8554611a..636b35d6ca68a 100644 --- a/.env.example +++ b/.env.example @@ -14,6 +14,10 @@ LOCAL_PORT=8889 # Where to run WordPress from. Valid options are 'src' and 'build'. LOCAL_DIR=src +# Whether or not to enable text compression (gzip) in the web server. +# Valid options are 'on' and 'off'. +LOCAL_NGINX_COMPRESSION=on + # The PHP version to use. Valid options are 'latest', and '{version}-fpm'. LOCAL_PHP=latest diff --git a/docker-compose.yml b/docker-compose.yml index cc2ed8d94975e..98b6dc3f4a048 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,13 +14,14 @@ services: environment: LOCAL_DIR: ${LOCAL_DIR-src} + LOCAL_NGINX_COMPRESSION: ${LOCAL_NGINX_COMPRESSION-on} volumes: - ./tools/local-env/default.template:/etc/nginx/conf.d/default.template - ./:/var/www # Load our config file, substituting environment variables into the config. - command: /bin/sh -c "envsubst '$$LOCAL_DIR' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'" + command: /bin/sh -c "envsubst '$$LOCAL_DIR $$LOCAL_NGINX_COMPRESSION' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'" depends_on: php: diff --git a/tools/local-env/default.template b/tools/local-env/default.template index a2ff1d4882092..4d8dec3c131fc 100644 --- a/tools/local-env/default.template +++ b/tools/local-env/default.template @@ -15,7 +15,7 @@ server { absolute_redirect off; - gzip on; + gzip ${LOCAL_NGINX_COMPRESSION}; gzip_vary on; gzip_proxied any; gzip_comp_level 5; From b026c1b8089e1c71b23e680615f2986aef9670f7 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 16 Aug 2026 10:57:47 -0700 Subject: [PATCH 3/5] Make local Nginx compression opt-in Co-authored-by: Jeff Bowen --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6662856378edd..a590752d6634f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: environment: LOCAL_DIR: ${LOCAL_DIR-src} - LOCAL_NGINX_COMPRESSION: ${LOCAL_NGINX_COMPRESSION-on} + LOCAL_NGINX_COMPRESSION: ${LOCAL_NGINX_COMPRESSION-off} volumes: - ./tools/local-env/default.template:/etc/nginx/conf.d/default.template From c926236fd41052dc6b48432fd80c685fa99094c2 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 16 Aug 2026 11:33:38 -0700 Subject: [PATCH 4/5] Use LOCAL_NGINX_COMPRESSION=off by default in .env.example Co-authored-by: Jeff Bowen --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 636b35d6ca68a..dddbb4be4c260 100644 --- a/.env.example +++ b/.env.example @@ -16,7 +16,7 @@ LOCAL_DIR=src # Whether or not to enable text compression (gzip) in the web server. # Valid options are 'on' and 'off'. -LOCAL_NGINX_COMPRESSION=on +LOCAL_NGINX_COMPRESSION=off # The PHP version to use. Valid options are 'latest', and '{version}-fpm'. LOCAL_PHP=latest From fbb88d9270c4e7422b254c44491b7acca32f6416 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 16 Aug 2026 11:37:35 -0700 Subject: [PATCH 5/5] Fall back to `off` when the compression variable is empty Switch `LOCAL_NGINX_COMPRESSION` to the `:-` form of parameter expansion, so the default applies when the variable is set but empty as well as when it is unset entirely. The value is substituted straight into the nginx template as `gzip ${LOCAL_NGINX_COMPRESSION};`, so an empty value rendered `gzip ;` and nginx refused to start with "invalid number of arguments in gzip directive". Clearing the value in `.env` is an intuitive way to turn compression off, and it now yields `off` rather than a crash-looping web container. Co-authored-by: Jeff Bowen --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index a590752d6634f..02cd542c245db 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: environment: LOCAL_DIR: ${LOCAL_DIR-src} - LOCAL_NGINX_COMPRESSION: ${LOCAL_NGINX_COMPRESSION-off} + LOCAL_NGINX_COMPRESSION: ${LOCAL_NGINX_COMPRESSION:-off} volumes: - ./tools/local-env/default.template:/etc/nginx/conf.d/default.template