[wp-trac] [WordPress Trac] #52636: Add proper Cache-Control header to /wp-json REST endpoints

WordPress Trac noreply at wordpress.org
Thu Jan 18 15:06:49 UTC 2024


#52636: Add proper Cache-Control header to /wp-json REST endpoints
-------------------------+-----------------------
 Reporter:  isaumya      |       Owner:  (none)
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:
Component:  REST API     |     Version:
 Severity:  major        |  Resolution:
 Keywords:  needs-patch  |     Focuses:  rest-api
-------------------------+-----------------------
Changes (by isaumya):

 * status:  closed => reopened
 * resolution:  wontfix =>


Comment:

 Sorry to re-open this 3-year-old ticket again. But I've find something
 weird that I would like to share and ask for a proper way of handling
 this.

 So, earlier @TimothyBlynJacobs suggested using the
 `rest_send_nocache_headers` filter which works great for adding `no-cache`
 `Cache-Control` header to all WP Core rest endpoints.

 But testing over the last few years I have seen that despite using that
 above-mentioned filter in the code, REST endpoint added by other plugins
 like `/wp-json/autonami-webhook/sms/twilio/123` or `/wp-
 json/woofunnels/v1/worker` and there are many more cases like these where
 I do not see the `no-cache` `Cache-Control` header despite that filter
 being enabled.

 I think WP Core team should look into it and make sure if the above-
 mentioned filter is enabled, the proper `no-cache` `Cache-Control` header
 is added to the REST request regardless of whether the endpoint is WP Core
 endpoint or it a custom endpoint added by some external plugins.

 Currently, there is no way to achieve this despite using that filter. I
 even spoke to some plugin devs and they said that they are using WP Coding
 guidelines to build their REST endpoint and they have no idea why the core
 filter is not adding the `Cache-Control` header.

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


More information about the wp-trac mailing list