Page cache should strip unnecessary data from the response

Created on 6 January 2024, 11 months ago
Updated 19 February 2024, 9 months ago

Problem/Motivation

The page cache caches Symfony responses, this includes cacheabilityMetadata and attachments keys which aren't used by the page cache (cache tags for example are already in the headers).

If we strip these before we set the cache item, we should be able to reduce the size of cache entries, and the insert / get / unserialize might get a bit cheaper too.

Found while trying to figure out 🐛 OpenTelemetryNodePagePerformanceTest::testNodePageHotCache() is not hot enough Needs work but this isn't related.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Page cache 

Last updated 3 months ago

Created by

🇬🇧United Kingdom catch

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

Merge Requests

Comments & Activities

  • Issue created by @catch
  • Merge request !6050Remove attachments before setting the response. → (Open) created by catch
  • Status changed to Needs work 11 months ago
  • 🇬🇧United Kingdom catch

    Can't remove cacheability metadata - it might require creating a new response object from the old response or something to do that, but attachments can be removed it looks like.

  • Status changed to Needs review 11 months ago
  • 🇬🇧United Kingdom catch

    We can create a minimal response object with only the information we need.

    This doesn't make anything measurably faster according to a quick test with ab, but it does make it measurably smaller - so potentially still worth doing.

    Before:

    Server Software:        Apache/2.4.56
    Server Hostname:        drupal-dev.ddev.site
    Server Port:            443
    SSL/TLS Protocol:       TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128
    Server Temp Key:        X25519 253 bits
    TLS Server Name:        drupal-dev.ddev.site
    
    Document Path:          /node/1
    Document Length:        43720 bytes
    
    Concurrency Level:      1
    Time taken for tests:   4.660 seconds
    Complete requests:      500
    Failed requests:        0
    Total transferred:      22073000 bytes
    HTML transferred:       21860000 bytes
    Requests per second:    107.31 [#/sec] (mean)
    Time per request:       9.319 [ms] (mean)
    Time per request:       9.319 [ms] (mean, across all concurrent requests)
    Transfer rate:          4626.08 [Kbytes/sec] received
    
    
    MariaDB [db]> SELECT LENGTH(data) FROM cache_page;
    +--------------+
    | LENGTH(data) |
    +--------------+
    |        52133 |
    +--------------+
    

    After:

    Server Software:        Apache/2.4.56
    Server Hostname:        drupal-dev.ddev.site
    Server Port:            443
    SSL/TLS Protocol:       TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128
    Server Temp Key:        X25519 253 bits
    TLS Server Name:        drupal-dev.ddev.site
    
    Document Path:          /node/1
    Document Length:        43720 bytes
    
    Concurrency Level:      1
    Time taken for tests:   4.682 seconds
    Complete requests:      500
    Failed requests:        0
    Total transferred:      22073000 bytes
    HTML transferred:       21860000 bytes
    Requests per second:    106.79 [#/sec] (mean)
    Time per request:       9.364 [ms] (mean)
    Time per request:       9.364 [ms] (mean, across all concurrent requests)
    Transfer rate:          4604.00 [Kbytes/sec] received
    
    MariaDB [db]> SELECT LENGTH(data) FROM cache_page;
    +--------------+
    | LENGTH(data) |
    +--------------+
    |        45250 |
    +--------------+
    
    
  • Status changed to Needs work 11 months ago
  • 🇺🇸United States smustgrave

    Seems to have a test failure.

  • 🇮🇳India kalpanajaiswal

    Remove library, drupal settings and other attachments from response.

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.6
    last update 9 months ago
    Patch Failed to Apply
Production build 0.71.5 2024