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

CommentFileSizeAuthor
#2 gzip-aggregate-34707367-1.patch1.54 KBmikeryan

Issue fork drupal-3407367

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mikeryan created an issue. See original summary.

mikeryan’s picture

StatusFileSize
new1.54 KB
mikeryan’s picture

Status: Active » Needs work
mikeryan’s picture

Tests pass - guess I didn't break anything!

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

plach made their first commit to this issue’s fork.

plach’s picture

Priority: Normal » Major

Rerolled the patch on the current HEAD. Raising priority to major since the performance gain may be significant.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.