WordPress / WordPress/performance

Leverage template enhancement output buffer for Server Timing in WP 6.9

Open
#2,225 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Plugin] Performance Lab [Type] Enhancement ContributorDay
Dominant language
PHP
Stars
461
Forks
165
Avg merge
11h 12m
Merged PRs (30d)
28

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in plugins/performance-lab/includes/server-timing/class-perflab-server-timing.php at the template_redirect and template_include handling, then review Core-43258 and changeset r60936 for the new WordPress hooks. Use the available function and hooks conditionally for WordPress 6.9, while preserving the existing behavior when they are unavailable. Done means Server-Timing is sent correctly with and without output buffering.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
performance
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.