CloudFlare Free/PRO Plan with Woocommerce site


I always got errors when viewing my cart/checkout page and I find this tutorial:

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 => {

async function noCacheOnCookie(request) {
  // Determine which group this request is in.
  const cookie = request.headers.get('Cookie')
  const cacheSeconds = 604800
  if (cookie 
    && (
      || 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.

This topic was automatically closed after 31 days. New replies are no longer allowed.