Skip to content

Leverage template enhancement output buffer for Server Timing in WP 6.9 #2225

@westonruter

Description

@westonruter

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

public function add_hooks(): void {
if ( $this->use_output_buffer() ) {
add_action( 'template_redirect', array( $this, 'start_output_buffer' ), PHP_INT_MIN );
} else {
add_filter( 'template_include', array( $this, 'on_template_include' ), PHP_INT_MAX );
}
}

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Plugin] Performance LabIssue relates to work in the Performance Lab Plugin only[Type] EnhancementA suggestion for improvement of an existing feature

    Projects

    Status

    Not Started/Backlog 📆

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions