Moving the send_headers action to later in the load

As of WordPress 6.1, the send_headers hook has been moved to slightly later in the WordPress loading routine (ticket). Historically, all the is_ functions (like is_singular) wouldn’t work when you were determining which headers to send. With this change, moving `send_headers` to after WordPress parses the query, those functions now work properly.

People can now have more control over things like:

  • Managing caching behavior
  • Preloading assets with HTTP rel=preload headers
  • Conditionally executing redirects, and managing other non-200 status scenarios

Currently, these types of scenarios are often filtered in late actions like template_redirect; which is semantically confusing, and inefficient.

There’s a good example of code that becomes easier with this. In fact, it has already been changed in this ticket: the X-Pingback HTTP header only needs to be sent for posts, and can now be sent at the right time (commit).

Let’s see what it means in terms of load order:

Action sequence before this change

  • wp_loaded
  • parse_request
  • send_headers
  • parse_query
  • pre_get_posts — WP main query.

Action sequence after this change

  • wp_loaded
  • parse_request
  • parse_query
  • pre_get_posts — WP main query.
  • send_headers

This should not affect any of your existing code negatively unless you were using send_headers to do things that really should have been happening on wp_loaded or parse_request. So please check your code for that! If you were doing that, just changing to an earlier hook should fix your problem.

For new code, you can now happily use all the is_ functions.

Props to @jonoaldersonwp, @sergeybiryukov, @aristath, @milana_cap for reviewing this post.

#6-1, #dev-notes, #performance

A WordPress Commenter

Recent Posts

Browse the New Mercantile Swag Store

Mercantile, the official swag store of the WordPress project, has a newly redesigned storefront with…

3 days ago

Kim Parsell Memorial Scholarship Opens for WordCamp US 2026

Applications are now open for the 2026 Kim Parsell Memorial Scholarship, which supports one active…

6 days ago

Global Partners Across the First Half of the 2026 WordPress Event Season

This post recaps how the WordPress project’s five Global Partners — Jetpack, WordPress.com, WooCommerce, Bluehost,…

7 days ago

Performance Chat Summary: 16 June 2026

The full chat log is available beginning here on Slack. WordPress Performance Trac tickets @westonruter…

1 week ago

What Happened at WordCamp Europe 2026

WordCamp Europe, the biggest WordPress conference in Europe, spent the first week of June in…

3 weeks ago

Protect The Shire

tl;dr: Temporary 24-hour cooldown period for plugin/theme releases before auto-updates. AI can give defenders an…

3 weeks ago