Problem/Motivation
Discovered while poking around in #3612177: Update autoload classmap for Symfony runtime and etc.
PageCache::set() stores a complete HtmlResponse object.
HtmlResponseAttachmentsProcessor leaves the attachments on the response, so every cache hit unserializes the library list, the drupalSettings array, the html_head render arrays and the CacheableMetadata.
PageCache::lookup() only uses the status, headers and content.
Steps to reproduce
Proposed resolution
Only cache a Response containing the data that PageCache::lookup() needs.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Comments
Comment #2
longwaveImplemented the change and a test.
In the test this saves about 1.7Kb per page cache entry, but this is in the Stark theme - realistic themes will have more libraries, html_head entries, etc.