OCMLABS/MODULE-CLOUDFLARE · SYSTEM SETTINGS

Configure the connection, zone, edge cache, purging, analytics and real IP handling in Stores > Configuration

  • Magento
  • Adobe Commerce
  • Hyvä

Module settings live at Stores > Configuration > OCMLabs > Cloudflare (section ocmlabs_cloudflare). Scope is per group: connection and purging are global, the zone and edge cache settings are per website so each website can map to its own zone. Nothing is store-view scoped.

General

Default scope, except where noted.

FieldDefaultDescription
Enable Cloudflare IntegrationNoKill switch for the whole module. Off means no edge headers, no real IP handling, no purges and no module cron work.
API TokenemptyEncrypted at rest. Needs Zone:Read, Zone:Cache Purge, Zone:Settings:Read, Zone:Settings:Edit, Zone:Cache Rules:Edit and Analytics:Read. Can be overridden at website scope to use a different Cloudflare account for that website.
Account IDemptyOptional. Detected from the API token when left blank. Website scope allowed.
Debug LoggingNoWrites every Cloudflare API call to var/log/ocmlabs_cloudflare.log. The token is redacted.
Test ConnectionbuttonVerifies the token and lists the zones it can see.

Zone

Website scope.

FieldDefaultDescription
Zone IDemptyThe Cloudflare zone that serves this website.
Detect ZonebuttonLooks the zone up from the website’s base URL hostnames. Only shown at website scope.
Storefront HostsemptyOptional, one host per line. Overrides the hosts derived from the website’s base URLs. Used in cache rule expressions and by the live health probes.
Storefront OriginemptyOptional origin address used by the “Origin sends edge cache headers” health check, which fetches a page directly from your server rather than through Cloudflare. Accepts a host, host:port, an IP or a URL. TLS certificate verification is skipped for this fetch, because an origin certificate is rarely valid for the public host.

Edge Cache

Website scope.

FieldDefaultDescription
Enable Edge Caching of HTMLNoWhen No, every storefront response carries Cache-Control: private, no-store, so a zone with a “Cache Everything” rule cannot cache HTML by accident. When Yes, pages Magento’s full page cache treats as public get public, max-age=0, s-maxage=<ttl>.
Edge TTL (seconds)emptyHow long Cloudflare keeps a page. Blank inherits the full page cache TTL (system/full_page_cache/ttl).
Bypass Pathssee belowOne path prefix per line. Requests under these paths are never cached at the edge, and the “Bypass protected paths” cache rule is built from this list. {admin} is replaced with your real admin frontName.
Vary HandlingBypassWhat happens to visitors carrying the X-Magento-Vary cookie (a non-default store view, currency or customer group). Bypass the edge cache for varied requests works on every plan: those visitors are served by Magento’s full page cache. Vary on cache key (Enterprise only) adds the cookie to the cache key so each variant is cached separately.
Cache Query StringsYesWhen No, any request with a query string skips the edge cache, and a “Bypass query strings” cache rule is added.

The default Bypass Paths list:

/checkout
/customer
/sales
/wishlist
/paypal
/rest
/graphql
{admin}
/downloadable
/newsletter/subscriber
/review/product/post
/catalogsearch/advanced/result
/contact

Add the callback paths of your payment and shipping extensions to this list.

Purging

Default scope.

FieldDefaultDescription
Purge ModeBy cache tagBy cache tag (recommended) purges exactly the tags Magento invalidated. By URL resolves product, category and CMS page tags to URLs, for setups where something between Magento and Cloudflare strips the Cache-Tag header. Purge everything purges the whole zone on every invalidation.
Purge AsynchronouslyYesQueue purges through the ocmlabsCloudflarePurge consumer so saving a product is not slowed by an API round trip. With No, the purge runs inside the admin save that triggered it.
Purge Everything on Full Page Cache CleanYesFlushing or refreshing the full page cache in the admin, or bin/magento cache:clean full_page, also purges the zone.
Max URLs per Tag500In URL mode, a tag that resolves to more URLs than this purges everything instead.

Analytics

Default scope.

FieldDefaultDescription
Enable AnalyticsYesShows the Analytics tab on the dashboard and lets the warm-up cron fetch data.
Analytics Cache TTL (seconds)900How long fetched analytics are cached in the ocmlabs_cloudflare cache type before the next GraphQL call.

Real IP

Default scope.

FieldDefaultDescription
Trust CF-Connecting-IPYesUse the CF-Connecting-IP header as the visitor IP for requests whose TCP peer is a Cloudflare address. Requests from any other peer keep REMOTE_ADDR, so the header cannot be spoofed by hitting the origin directly. See Real Visitor IP.

Configuration paths

For bin/magento config:set and env.php overrides, every field sits under ocmlabs_cloudflare/<group>/<field>:

ocmlabs_cloudflare/general/enabled
ocmlabs_cloudflare/general/api_token
ocmlabs_cloudflare/general/account_id
ocmlabs_cloudflare/general/debug_logging
ocmlabs_cloudflare/zone/zone_id
ocmlabs_cloudflare/zone/storefront_hosts
ocmlabs_cloudflare/zone/storefront_origin
ocmlabs_cloudflare/edge_cache/edge_cache_enabled
ocmlabs_cloudflare/edge_cache/edge_ttl
ocmlabs_cloudflare/edge_cache/bypass_paths
ocmlabs_cloudflare/edge_cache/vary_handling (bypass | cache_key)
ocmlabs_cloudflare/edge_cache/cache_query_strings
ocmlabs_cloudflare/purging/purge_mode (tag | url | everything)
ocmlabs_cloudflare/purging/purge_async
ocmlabs_cloudflare/purging/purge_on_fpc_clean
ocmlabs_cloudflare/purging/max_urls_per_tag
ocmlabs_cloudflare/analytics/analytics_enabled
ocmlabs_cloudflare/analytics/analytics_cache_ttl
ocmlabs_cloudflare/real_ip/trust_cf_connecting_ip

Set the token with --encrypt:

Terminal window
bin/magento config:set --encrypt ocmlabs_cloudflare/general/api_token "<token>"
bin/magento config:set --scope=websites --scope-code=base ocmlabs_cloudflare/zone/zone_id "<zone id>"

See also

In this module