CloudFlare Free/PRO Plan with Woocommerce site

Hello

I always got errors when viewing my cart/checkout page and I find this tutorial: https://support.cloudflare.com/hc/en-us/articles/236166048-Caching-Static-HTML-with-WordPress-WooCommerce?flash_digest=02a7447562bdde23db648020091d1fefe266936b

It said in free plan we cannot enable " Bypass Cache on Cookie" for wordpress/woocommerce.
Is it possible to add this feature in PRO plan? For Business plan it is too expensive for small e-commerce site.

Please advise.

You can use Workers to emulate Bypass Cache on Cookie, but Workers charges add up for high-traffic sites.

@eva2000 dug this up for me:

// Stop CF edge from caching your site when specific wordpress cookies are present
addEventListener('fetch', event => {
  event.respondWith(noCacheOnCookie(event.request))
})

async function noCacheOnCookie(request) {
  // Determine which group this request is in.
  const cookie = request.headers.get('Cookie')
  const cacheSeconds = 604800
  if (cookie 
    && (
      cookie.includes(`wordpress_logged`)
      || cookie.includes(`comment_`)
      || cookie.includes(`wordpress_sec`)
    )) {
    const bustedRequest = new Request(request, { cf: { cacheTtl: -1 } })
    const response = await fetch(bustedRequest)

    const newHeaders = new Headers(response.headers)
    newHeaders.append('wp-cache-busted', `true`)
    return new Response(response.body, {
      status: response.status,
      statusText: response.statusText,
      headers: newHeaders
    })
  } else {
    // Edge Cache for 7 days
    return fetch(new Request(request, { cf: { cacheTtl: cacheSeconds } }))
  }
}

Does the code above do anything to woocommerce cart / checkout page?

It’s Bypass on Cookie. Just make sure you have a cookie.includes statement for the Woocommerce cookie.

And if Woocommerce sets that cookie, the user’s visit will bypass caching.