Repository navigation
Conversation
Match fpm-nginx's performance.conf: Cache-Control for assets, media and fonts, set only when the response has none, and CORS for fonts. Enable mod_expires for .htaccess rules, and remove mod_deflate's -gzip ETag, which never matched in If-None-Match.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #717. fpm-apache sends no cache headers for static files, and
<IfModule mod_expires.c>blocks in.htaccessare skipped becauseexpiresis not enabled. fpm-nginx has hadCache-Controlfor assets since #487.This enables
mod_expiresand adds aperformance.conf, enabled by default likesecurity.conf, with the same extensions andCache-Control: public, max-age=31536000, immutableas fpm-nginx, plusAccess-Control-Allow-Origin: *for fonts. The header is set withHeader set … "expr=-z %{resp:Cache-Control}", so mod_expires rules andHeader setorHeader always setin.htaccesstake precedence;setifemptyonly sees the onsuccess table and left twoCache-Controlheaders next to analwaysrule.<FilesMatch>matches the served file, so a missing asset rewritten toindex.phpgets no header from here, unlike nginx'stry_files.It also sets
DeflateAlterETag Remove. mod_deflate's default-gzipETag never matches inIf-None-Match, so compressed responses were never revalidated with a 304. Without the ETag, browsers useIf-Modified-Sinceand get one.NoChangewould fix the 304 too, but gives gzip and identity one strong ETag, and a mixedIf-Rangerequest then gets a 206 cut from the gzip bytes.One behaviour change: existing
mod_expiresblocks in apps'.htaccessfiles now take effect.Tested on
serversideup/php:8.5-fpm-apache(Apache 2.4.69) with the changed files layered on top: the headers for assets and fonts, precedence ofExpiresByType,Header setandHeader always setin.htaccess, no header for 404s and rewritten requests, 304 for a gzip response withIf-Modified-Since,/healthcheckunchanged,apache2ctl -t. ShellCheck, hadolint andscripts/tests/run.shpass.Fixes #735