• Resolved lbenevento

    (@lbenevento)


    My cart endpoints are getting cached. I’ve read that it is supposed to avoid doing that by default but for some reasons it’s not.

    This is my report number JFNCGDGW.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support qtwrk

    (@qtwrk)

    please try go to Cache -> Cache REST API , set it to OFF, save and purge all.

    Thread Starter lbenevento

    (@lbenevento)

    If that’s for you to test something it’s now disabled!

    Plugin Support qtwrk

    (@qtwrk)

    [root@v220221044927204975 ~]# curl -I -XGET https://api.zeroapp.store/wp-json/wc/store/v1/cart/items
    HTTP/2 200
    x-powered-by: PHP/7.4.33
    content-type: application/json; charset=UTF-8
    x-robots-tag: noindex
    link: <https://api.zeroapp.store/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
    nonce: 65852c6884
    nonce-timestamp: 1684970326
    user-id: 0
    cart-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidF9hYzFjNGVhMTAzOTRiODNjOWMwZDc3MzljZGVhNDkiLCJleHAiOjE2ODUxNDMxMjYsImlzcyI6IndjXC9zdG9yZVwvdjEiLCJpYXQiOjE2ODQ5NzAzMjZ9.7CTnVHWPKwI7YSHksu4sfPXqOkGhpK9kHjABzpl6vtA
    x-wc-store-api-nonce: 65852c6884
    allow: GET, POST, DELETE
    x-litespeed-tag: f18_HTTP.200
    vary: Origin
    x-litespeed-cache-control: no-cache
    date: Wed, 24 May 2023 23:18:46 GMT
    server: LiteSpeed
    platform: hostinger
    content-security-policy: upgrade-insecure-requests
    alt-svc: h3=":443"; ma=2592000, h3-29=":443"; ma=2592000, h3-Q050=":443"; ma=2592000, h3-Q046=":443"; ma=2592000, h3-Q043=":443"; ma=2592000, quic=":443"; ma=2592000; v="43,46"
    

    it shows x-litespeed-cache-control: no-cache which means plugin is not caching it

    Thread Starter lbenevento

    (@lbenevento)

    I set the Cache REST API option to off as you requested. It’s not caching it now but it was before and it will if I re enable REST API caching.

    Edit: I set it to on again so you can see the caching in action.

    • This reply was modified 3 years ago by lbenevento.
    • This reply was modified 3 years ago by lbenevento.
    Plugin Support qtwrk

    (@qtwrk)

    huh ? I don’t understand

    if you want to REST API not be cached , then you should keep that option OFF, no ?

    Thread Starter lbenevento

    (@lbenevento)

    Okay so, quoting what I believe is an official blog post by LiteSpeed:

    For starters, if WooCommerce says something is cacheable, then LSCache will cache it. Alternately, if WooCommerce doesn’t want something cached (like, for instance, the Cart, My Account, and Checkout), LiteSpeed will automatically respect that, and will not cache those pages. There’s no extra configuration required.

    https://blog.litespeedtech.com/2017/05/24/wpw-using-lscache-with-woocommerce/

    That’s to say that yes, I want to cache REST APIs. I don’t want to cache what is not supposed to be cached like the Cart, Checkout and whatever else. But I do want the cache on for, for instance, products.

    Hopefully that’s a bit clearer!

    • This reply was modified 3 years ago by lbenevento.
    Plugin Support qtwrk

    (@qtwrk)

    that depends on W C, in WP system , there is a constant called DONOTCACHEPAGE , if this constant is defined, we treat it as no cache and honor it

    but it looks like WC doesn’t define this on REST API

    you can use Cache -> Exclude -> Do not Cache URI , add these wp-json/wc/store/xxxx as the ones you don’t want to be cached

    Thread Starter lbenevento

    (@lbenevento)

    Oh okay, got it! Thank you for the alternative.

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

The topic ‘WC Store API cart is cached.’ is closed to new replies.