[wp-trac] [WordPress Trac] #31200: wp_redirect Missing Body - Causes Performance Issues

WordPress Trac noreply at wordpress.org
Tue Feb 18 23:26:16 UTC 2025


#31200: wp_redirect Missing Body - Causes Performance Issues
--------------------------+--------------------------
 Reporter:  tripsis       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  General       |     Version:  4.1
 Severity:  normal        |  Resolution:  invalid
 Keywords:  needs-patch   |     Focuses:  performance
--------------------------+--------------------------
Changes (by pbearne):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 I had a look at adding a meta tag redirect to the output

 It seems that while well-intentioned (perhaps for very old browsers), this
 is generally problematic and redundant.

 Here's why it's problematic:

 * **Redundancy:** Modern browsers respect the `Location` header and
 perform the redirect immediately. The meta refresh is unnecessary and adds
 extra processing.
 * **SEO:** Search engines generally follow the `Location` header. Adding a
 meta refresh might confuse them, potentially diluting link juice or
 causing indexing issues.
 * **User Experience:**  A fast redirect via the `Location` header is
 seamless. The meta refresh introduces a slight delay and an unnecessary
 interstitial page, potentially disrupting the user experience.
 * **Interference with Caching:** The outputted HTML might be cached,
 leading to stale redirects.

 **Recommendation:**  Remove the added code block entirely.  The existing
 `header("Location: ...")` is sufficient for proper redirection. The
 `wp_redirect_force_status_header` filter seems designed to control this
 problematic behaviour, but defaulting to `true` makes the problem the
 default.  A better approach would be to default it to `false` and only
 enable it in very specific cases where the `Location` header is known to
 be unreliable.

 In short, the diff makes WordPress redirects less efficient and
 potentially harmful.  Reverting this change is recommended.

 so I am going to close this ticket as won't fix

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/31200#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list