CloudFlare recommended Caching rules for Magento2 website

What is the name of the domain?

What is the error message?

NA

What is the issue you’re encountering

NA

What steps have you taken to resolve the issue?

Our abc.com website is a Magento2 website hosted on cPanel server with DNS on Cloudflare.

Currently we have 4 cache rules setup for it.

  1. Bypass checkout, cart, customer and admin [(http.request.uri.path contains “/checkout*”) or (http.request.uri.path contains “/cart*”) or (http.request.uri.path contains “/customer*”) or (http.request.uri.path contains “/admin*”) or (http.request.uri.path contains “/rest/") or (http.request.uri.path contains "/graphql”)]

  2. Static content for 1 day
    (http.host eq “www.abc.com” and starts_with(http.request.uri, “/static”))

  3. Media content for 1 day
    (http.host eq “www.abc.com” and starts_with(http.request.uri, “/media”))

  4. Website content (Use cache-control header if present, bypass cache if not and Respect origin TTL)
    (http.host eq “www.abc.com”)

Please suggest if these rules are OK and any other rules need to be added ?

I’d say you shouldn’t cache the HTML on Cloudflare since it’s the same as running any eCommerce shop such as WooCommerce, which would result in misbehave of the cache and experience of your Website visitor seeing what they shouldn’t see or wrong cart items added from another “cached version” of the page/session.

You can page cache HTML Magento on the origin and serve it like that as cf-cache-status: DYNAMIC with “Respect Origin Headers” selected for Browser Cache TTL.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.