performance icon indicating copy to clipboard operation
performance copied to clipboard

Leverage template enhancement output buffer for Server Timing in WP 6.9

Open westonruter opened this issue 1 year ago • 2 comments

Performance Lab currently opens its own output buffer at template_redirect and sends the Server-Timing response header during template_include:

https://github.com/WordPress/performance/blob/8368b58a03566b68225065b6c4897735752a704e/plugins/performance-lab/includes/server-timing/class-perflab-server-timing.php#L239-L245

In WordPress 6.9 we can now leverage the template enhancement output buffer introduced via Core-43258 (see r60936).

When the wp_start_template_enhancement_output_buffer() function exists, we can skip starting our own output buffer, and instead use the wp_template_enhancement_output_buffer filter.

Additionally, when output buffering is not desired, the new wp_before_include_template action can be used to send the Server-Timing instead of using the template_include filter.

See also:

  • #2224

westonruter avatar Oct 15 '25 17:10 westonruter

Depends on https://github.com/WordPress/performance/issues/2354

MarcinDudekDev avatar Jun 04 '26 12:06 MarcinDudekDev

I've opened #2515 to migrate the Performance Lab Server-Timing header to the WordPress 6.9 template enhancement output buffer (wp_finalized_template_enhancement_output_buffer when output buffering is enabled, wp_before_include_template otherwise).

This is the Server-Timing counterpart to the Optimization Detective migration in #2224, and similarly depends on the 6.9 minimum-version bump (#2354). Full CI is green.

MarcinDudekDev avatar Jun 04 '26 13:06 MarcinDudekDev