Cron-generated .htaccess files invalid, breaking full-site rendering

Created on 17 October 2023, about 1 year ago
Updated 22 May 2024, 7 months ago

Problem/Motivation

The .htaccess files generated during cron through \Drupal\advagg\Asset::generateHtaccess are missing the "E=no-brotli:1" flag, resulting in serving double Brotli-compressed assets.

The content-type header for gzipped assets has also been statically set to "application/javascript" when it should interpolate the function-scoped $type variable.

Originally, I was experiencing what I believed were corrupt assets as noted in the Compression Option's "Gzip" settings toggles, which reads "This should be enabled unless you are experiencing corrupted compressed asset files." This was due to the double-compression of assets, and resulted in the compressed files being served in plain text.

This may be a fix for that issue, as well.

Steps to reproduce

Enable Advanced Aggregation and run its related cron job. Check the resulting .htaccess files located at public://js/optimized/.htaccess and public://css/optimized/.htaccess.

Proposed resolution

Replace RewriteRule \.{$extension}\.br$ - [T={$type},E=no-gzip:1] with RewriteRule \.{$extension}\.br$ - [T={$type},E=no-gzip:1,E=no-brotli:1].

Replace RewriteRule \.{$extension}\.gz$ - [T=application/javascript,E=no-gzip:1] with RewriteRule \.{$extension}\.gz$ - [T={$type},E=no-gzip:1,E=no-brotli:1].

Remaining tasks

Replace relevant .htaccess directives.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs review

Version

6.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States FrankieD3

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024