Make WordPress Core

Changeset 63308


Ignore:
Timestamp:
08/16/2026 06:46:59 PM (5 hours ago)
Author:
westonruter
Message:

Build/Test Tools: Allow text compression in the local 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 can be served compressed, matching normal production behavior. Without compression, frontend performance analysis against the local environment is not representative of a real user's experience.

Compression is controlled by a new LOCAL_NGINX_COMPRESSION option, and it defaults to off so that it is opt-in.

Since this changes docker-compose.yml in addition to the nginx template, existing checkouts need to recreate the web server container to pick up the change.

Developed in https://github.com/WordPress/wordpress-develop/pull/12529.
Follow-up to r45745, r45783.

Props westonruter, jblz.
Fixes #65634.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/.env.example

    r62407 r63308  
    1414# Where to run WordPress from. Valid options are 'src' and 'build'.
    1515LOCAL_DIR=src
     16
     17# Whether or not to enable text compression (gzip) in the web server.
     18# Valid options are 'on' and 'off'.
     19LOCAL_NGINX_COMPRESSION=off
    1620
    1721# The PHP version to use. Valid options are 'latest', and '{version}-fpm'.
  • trunk/docker-compose.yml

    r62937 r63308  
    1515    environment:
    1616      LOCAL_DIR: ${LOCAL_DIR-src}
     17      LOCAL_NGINX_COMPRESSION: ${LOCAL_NGINX_COMPRESSION:-off}
    1718
    1819    volumes:
     
    2122
    2223    # Load our config file, substituting environment variables into the config.
    23     command: /bin/sh -c "envsubst '$$LOCAL_DIR' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
     24    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;'"
    2425
    2526    depends_on:
  • trunk/tools/local-env/default.template

    r58097 r63308  
    1515
    1616        absolute_redirect off;
     17
     18        gzip ${LOCAL_NGINX_COMPRESSION};
     19        gzip_vary on;
     20        gzip_proxied any;
     21        gzip_comp_level 5;
     22        gzip_min_length 256;
     23        gzip_types
     24                application/javascript
     25                text/javascript
     26                application/json
     27                application/xml
     28                application/rss+xml
     29                text/css
     30                text/plain
     31                image/svg+xml;
    1732
    1833        if (!-e $request_filename) {
Note: See TracChangeset for help on using the changeset viewer.