REST Endpoint cached despite disallowed
-
Hi there,
We’ve got a custom REST API endpoint that provides application health information. We’d like to ensure that it is never cached.
To do this we have:
1. Made sure the endpoint callback calls
do_action( 'litespeed_control_set_nocache', 'nocache due to application health' );
.
2. Told the API endpoint to respond with no-cache headers.Despite this, the endpoint remains served with a x-litespeed-cache hit header.
Next, we tried manually adding the endpoint URL under Cache > Excludes > Do Not Cache URIs. This is the scenario that we’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.
Finally, we disabled the option of caching the REST API completely in Cache > Cache. We still get a cache hit.
Every time we purge the cache, the endpoint refreshes successfully. But on subsequent hits, they are always cached. Regardless of any rules.
This is a multisite install, but changing network enable cache has no effect. Disabling the cache completely disables the cache hits as expected.
The server is a Litespeed server.
- The topic ‘REST Endpoint cached despite disallowed’ is closed to new replies.