• Resolved dgchessablecom

    (@dgchessablecom)


    I use Cloudflare for caching. RestAPI::oembed currently responds with a 202 status code which prevents caching of the JSON response. Note the CF-Cache-Status: MISS header in the output below. Changing the response code to 200 shows CF-Cache-Status: HIT.

    I believe Cloudflare’s behaviour of only caching on 200 is correct here. Looking at RFC 7231, 202 responses aren’t meant to be cached:

    The 202 (Accepted) status code indicates that the request has been
    accepted for processing, but the processing has not been completed.
    The request might or might not eventually be acted upon, as it might
    be disallowed when processing actually takes place. (…)

    The 202 response is intentionally noncommittal. Its purpose is to
    allow a server to accept a request for some other process (perhaps a
    batch-oriented process that is only run once per day) without
    requiring that the user agent’s connection to the server persist
    until the process is completed. The representation sent with this
    response ought to describe the request’s current status and point to
    (or embed) a status monitor that can provide the user with an
    estimate of when the request will be fulfilled.

    Since a full response body is being sent (the JSON in this case), the response code should be 200.

    With response code 202:

    curl 'https://championschesstour.com/wp-json/embedpress/v1/oembed/twitch?maxwidth=800&maxheight=1000&url=https%3A%2F%2Fwww.twitch.tv%2Fchess24&dnt=1&format=json' -v
    *   Trying 104.24.126.104...
    * TCP_NODELAY set
    * Connected to championschesstour.com (104.24.126.104) port 443 (#0)
    * ALPN, offering h2
    * ALPN, offering http/1.1
    * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
    * successfully set certificate verify locations:
    *   CAfile: /etc/ssl/cert.pem
      CApath: none
    * TLSv1.2 (OUT), TLS handshake, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Server hello (2):
    * TLSv1.2 (IN), TLS handshake, Certificate (11):
    * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
    * TLSv1.2 (IN), TLS handshake, Server finished (14):
    * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
    * TLSv1.2 (OUT), TLS change cipher, Client hello (1):
    * TLSv1.2 (OUT), TLS handshake, Finished (20):
    * TLSv1.2 (IN), TLS change cipher, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Finished (20):
    * SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
    * ALPN, server accepted to use h2
    * Server certificate:
    *  subject: C=US; ST=CA; L=San Francisco; O=Cloudflare, Inc.; CN=sni.cloudflaressl.com
    *  start date: Oct 14 00:00:00 2020 GMT
    *  expire date: Oct 13 23:59:59 2021 GMT
    *  subjectAltName: host "championschesstour.com" matched cert's "championschesstour.com"
    *  issuer: C=US; O=Cloudflare, Inc.; CN=Cloudflare Inc ECC CA-3
    *  SSL certificate verify ok.
    * Using HTTP2, server supports multi-use
    * Connection state changed (HTTP/2 confirmed)
    * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
    * Using Stream ID: 1 (easy handle 0x7fd0bd806400)
    > GET /wp-json/embedpress/v1/oembed/twitch?maxwidth=800&maxheight=1000&url=https%3A%2F%2Fwww.twitch.tv%2Fchess24&dnt=1&format=json HTTP/2
    > Host: championschesstour.com
    > User-Agent: curl/7.54.0
    > Accept: */*
    >
    * Connection state changed (MAX_CONCURRENT_STREAMS updated)!
    < HTTP/2 202
    < date: Sat, 05 Dec 2020 12:07:51 GMT
    < content-type: application/json; charset=UTF-8
    < set-cookie: __cfduid=d3b0ca8058ec702414f251f7512fc054c1607170071; expires=Mon, 04-Jan-21 12:07:51 GMT; path=/; domain=.championschesstour.com; HttpOnly; SameSite=Lax
    < x-robots-tag: noindex
    < link: <https://championschesstour.com/wp-json/>; rel="https://api.w.org/"
    < x-content-type-options: nosniff
    < access-control-expose-headers: X-WP-Total, X-WP-TotalPages, Link
    < access-control-allow-headers: Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type
    < allow: GET
    < vary: Origin,Accept-Encoding
    < cf-cache-status: MISS
    < cf-request-id: 06d46632b600002cfb8a89e000000001
    < expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
    < report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=Kvio0ezWJkqWGuWXOjerxHBMZCdMn3SvymI26xi%2BENCc3D%2FFpW5hksNGT0DCOcahNhvChamuL5OMRxw1pL1H3PB3FQkQL%2FGaDa2bIjXSC8kiXVXDhASd"}],"group":"cf-nel","max_age":604800}
    < nel: {"report_to":"cf-nel","max_age":604800}
    < server: cloudflare
    < cf-ray: 5fcda6312cd82cfb-LHR
    <
    * Connection #0 to host championschesstour.com left intact

    {“version”:”1.0″,”provider_name”:”Twitch”,”url”:”https:\/\/www.twitch.tv\/chess24″,”title”:””,”author_name”:””,”author_url”:””,”cache_age”:”0″,”embera_using_fake”:”1″,”width”:”420″,”height”:”315″,”type”:”channel”,”provider_url”:”https:\/\/twitch.tv”,”html”:”<iframe src=\”https:\/\/player.twitch.tv\/?channel=chess24&parent=championschesstour.com\” height=\”315\” width=\”420\” scrolling=\”no\” frameborder=\”0\” allowfullscreen=\”true\”><\/iframe>”,”provider_alias”:”twitch”,”wrapper_class”:””}

    With response code 200:

    curl ‘https://championschesstour.com/wp-json/embedpress/v1/oembed/twitch?maxwidth=800&maxheight=1000&url=https%3A%2F%2Fwww.twitch.tv%2Fchess24&dnt=1&format=json&#8217; -v
    * Trying 172.67.200.129…
    * TCP_NODELAY set
    * Connected to championschesstour.com (172.67.200.129) port 443 (#0)
    * ALPN, offering h2
    * ALPN, offering http/1.1
    * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
    * successfully set certificate verify locations:
    * CAfile: /etc/ssl/cert.pem
    CApath: none
    * TLSv1.2 (OUT), TLS handshake, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Server hello (2):
    * TLSv1.2 (IN), TLS handshake, Certificate (11):
    * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
    * TLSv1.2 (IN), TLS handshake, Server finished (14):
    * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
    * TLSv1.2 (OUT), TLS change cipher, Client hello (1):
    * TLSv1.2 (OUT), TLS handshake, Finished (20):
    * TLSv1.2 (IN), TLS change cipher, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Finished (20):
    * SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
    * ALPN, server accepted to use h2
    * Server certificate:
    * subject: C=US; ST=CA; L=San Francisco; O=Cloudflare, Inc.; CN=sni.cloudflaressl.com
    * start date: Oct 14 00:00:00 2020 GMT
    * expire date: Oct 13 23:59:59 2021 GMT
    * subjectAltName: host “championschesstour.com” matched cert’s “championschesstour.com”
    * issuer: C=US; O=Cloudflare, Inc.; CN=Cloudflare Inc ECC CA-3
    * SSL certificate verify ok.
    * Using HTTP2, server supports multi-use
    * Connection state changed (HTTP/2 confirmed)
    * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
    * Using Stream ID: 1 (easy handle 0x7f8faa80e000)
    > GET /wp-json/embedpress/v1/oembed/twitch?maxwidth=800&maxheight=1000&url=https%3A%2F%2Fwww.twitch.tv%2Fchess24&dnt=1&format=json HTTP/2
    > Host: championschesstour.com
    > User-Agent: curl/7.54.0
    > Accept: */*
    >
    * Connection state changed (MAX_CONCURRENT_STREAMS updated)!
    < HTTP/2 200
    < date: Tue, 15 Dec 2020 16:50:13 GMT
    < content-type: application/json; charset=UTF-8
    < set-cookie: __cfduid=dec28542532e550597fc8f2bf8459f4321608051013; expires=Thu, 14-Jan-21 16:50:13 GMT; path=/; domain=.championschesstour.com; HttpOnly; SameSite=Lax
    < x-robots-tag: noindex
    < link: <https://championschesstour.com/wp-json/&gt;; rel=”https://api.w.org/&#8221;
    < x-content-type-options: nosniff
    < access-control-expose-headers: X-WP-Total, X-WP-TotalPages, Link
    < access-control-allow-headers: Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type
    < allow: GET
    < vary: Origin,Accept-Encoding
    < cf-cache-status: HIT
    < age: 1010
    < expires: Tue, 15 Dec 2020 20:50:13 GMT
    < cache-control: public, max-age=14400
    < cf-request-id: 0708e84e1d0000fa78fe09f000000001
    < expect-ct: max-age=604800, report-uri=”https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct&#8221;
    < report-to: {“endpoints”:[{“url”:”https:\/\/a.nel.cloudflare.com\/report?s=YPtiXe8WNGRg27al1rC%2Bx%2BfROQ03dZE0aygjuUjyG9poq3U7ymgM8acoOd9H7kEHGJ%2FJTY1QXRfhTgOFZZMKtE1r8SYHBj4gtCwNzoNnzDOEHAbk8d2i”}],”group”:”cf-nel”,”max_age”:604800}
    < nel: {“report_to”:”cf-nel”,”max_age”:604800}
    < server: cloudflare
    < cf-ray: 6021a9902c3afa78-AMS
    <
    * Connection #0 to host championschesstour.com left intact
    {“version”:”1.0″,”provider_name”:”Twitch”,”url”:”https:\/\/www.twitch.tv\/chess24″,”title”:””,”author_name”:””,”author_url”:””,”cache_age”:”0″,”embera_using_fake”:”1″,”width”:”420″,”height”:”315″,”type”:”channel”,”provider_url”:”https:\/\/twitch.tv”,”html”:”<iframe src=\”https:\/\/player.twitch.tv\/?channel=chess24&parent=championschesstour.com\” height=\”315\” width=\”420\” scrolling=\”no\” frameborder=\”0\” allowfullscreen=\”true\”><\/iframe>”,”provider_alias”:”twitch”,”wrapper_class”:””}

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Nahid Hasan

    (@tushar284)

    Hi @dgchessablecom,

    Thank you so much for reporting this issue. Anyway, this has been addressed to our devs team already, hopefully you’ll find it fixed in our upcoming updates.

    Thanks for your kind understanding and patience.

    Have a nice day!

    Hi @dgchessablecom The issue has been fixed in the version 2.7.0. So, I am marking this ticket as resolved. If you are happy, rate us and share your valuable feedback and if you need help, please do not hesitate to contact us anytime.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Return 200 instead of 202 in RestAPI::oembed’ is closed to new replies.