Hi Edwin!
Surge will already cache public endpoints, such as wp-json/wp/v2/posts for example, as long as there’s no “Cache-Control: no-cache” header, authentication cookies or an Authorization (application password) header, then the response will be cached.
Here’s an example:
$ curl -v https://konstantin.blog/wp-json/wp/v2/posts -o /dev/null
< X-Cache: hit
Hope that answers your question!
K
Thread Starter
Anonymous User 14009747
(@anonymized-14009747)
Beautiful!
The rest api automatically injects the no-cache header, that’s why I didn’t find the cache hit.
Will test some more!
Depends on the endpoint. If it’s a private endpoint or if you are logged in, then yes, WordPress core will serve a no-cache header. If you’re hitting a public endpoint and still getting a no-cache header, then perhaps you’re logged in? Have you tried incognito mode?
I’ll be happy to investigate further if you could post the request and response headers here (blur out any authentication or other sensitive cookies/headers).
K