Compressed aggregates not delivered on first request

Created on 9 December 2023, 9 months ago

Problem/Motivation

We have observed that on the first request from a page with much Javascript, the aggregate is significantly larger than subsequent requests (e.g. 810k vs. 254k). A closer look at the aggregate requests showed that the first request is not gzipped (no Content-Encoding: gzip in the response headers).

Steps to reproduce

  1. drush cr
  2. Open the developer tools in your browser and select Network. Disable the browser cache and filter on JS.
  3. Load a page with a significant amount of Javascript and observe the size associated with your aggregated Javascript (e.g. js_PJixJTcRpBgmI1Wpr2HGyIcRPTPtYUT-6M0gt7Q42bk.js).
  4. Reload the page and observe the size associated with the same file. It is now significantly smaller.

Proposed resolution

AssetControllerBase::deliver() should, if dumpToUri has generated a .gz version of the asset, deliver that instead of the uncomporessed data, and set the Content-Encoding to gzip.

Remaining tasks

  • Add a failing test for the scenario.
  • Submit a fix for the scenario which passes the test.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
Asset libraryΒ  β†’

Last updated 1 day ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States mikeryan Murphysboro, IL, USA

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

Comments & Activities

Production build 0.71.5 2024