• Resolved Anonymous User 14009747

    (@anonymized-14009747)


    Hi Konstantin,

    Looks promissing this plugin. Will you also work on caching the output of the Rest API? I will gladly use it!

    Kind regards,

    Edwin

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konstantin Kovshenin

    (@kovshenin)

    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!

    Plugin Author Konstantin Kovshenin

    (@kovshenin)

    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

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Surge for Rest API’ is closed to new replies.