{"id":15175826,"date":"2021-12-18T09:56:07","date_gmt":"2021-12-18T09:56:07","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/rest-endpoint-cached-despite-disallowed\/"},"modified":"2021-12-18T09:56:59","modified_gmt":"2021-12-18T09:56:59","slug":"rest-endpoint-cached-despite-disallowed","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/rest-endpoint-cached-despite-disallowed\/","title":{"rendered":"REST Endpoint cached despite disallowed"},"content":{"rendered":"<p>Hi there,<\/p>\n<p>We&#8217;ve got a custom REST API endpoint that provides application health information. We&#8217;d like to ensure that it is never cached.<\/p>\n<p>To do this we have:<\/p>\n<p>1. Made sure the endpoint callback calls <code>do_action( &#039;litespeed_control_set_nocache&#039;, &#039;nocache due to application health&#039; );<\/code>.<br \/>\n2. Told the API endpoint to respond with no-cache headers.<\/p>\n<p>Despite this, the endpoint remains served with a x-litespeed-cache hit header.<\/p>\n<p>Next, we tried manually adding the endpoint URL under Cache &gt; Excludes &gt; Do Not Cache URIs. This is the scenario that we&#8217;d like to get away from doing with the action call, but just for debugging purposes. Still the same result. The response is served as a cache hit.<\/p>\n<p>Finally, we disabled the option of caching the REST API completely in Cache &gt; Cache. We still get a cache hit.<\/p>\n<p>Every time we purge the cache, the endpoint refreshes successfully. But on subsequent hits, they are always cached. Regardless of any rules.<\/p>\n<p>This is a multisite install, but changing network enable cache has no effect. Disabling the cache completely disables the cache hits as expected.<\/p>\n<p>The server is a Litespeed server.<\/p>\n","protected":false},"template":"","class_list":["post-15175826","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15175826","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15175826\/revisions"}],"predecessor-version":[{"id":15175829,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15175826\/revisions\/15175829"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=15175826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}