[wp-trac] [WordPress Trac] #50422: Prevent Browser Caching From Getting Involved With wp_redirect and wp_safe_redirect (Leaving the Browser to Purely Honor the Redirect Code Used)

WordPress Trac noreply at wordpress.org
Wed Mar 19 16:22:34 UTC 2025


#50422: Prevent Browser Caching From Getting Involved With wp_redirect and
wp_safe_redirect (Leaving the Browser to Purely Honor the Redirect Code
Used)
-------------------------------------+------------------------------
 Reporter:  KZeni                    |       Owner:  (none)
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  General                  |     Version:  5.4.2
 Severity:  normal                   |  Resolution:
 Keywords:  needs-testing has-patch  |     Focuses:
-------------------------------------+------------------------------

Comment (by shoelaced):

 Replying to [comment:8 tha_sun]:

 > The current proposal won't fix in my opinion, because it would enforce a
 behavior that does not make sense for the vast majority of redirect use
 cases.

 In that case, perhaps it would make sense to add a `$cache_headers`
 parameter to the redirect functions, defaulting to `true`, that would
 simplify these less common cases? Obviously it would still require a
 conscious choice by the developer, but at least then it would be more
 visible and appear in IDE tools that display the documentation of WP
 functions.

 Mainly my annoyance with this came from spending a lot of time debugging,
 and I did check the function's listing in the WP docs multiple times
 during that time to make sure I was using it correctly, but it wasn't
 until I finally noticed @KZeni 's note at the bottom that I learned about
 this issue and found this ticket. Being able to see the option in the
 parameters would have at least made me aware much sooner that this could
 be a potential issue and provided a way to disable it without yet more
 research.

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


More information about the wp-trac mailing list