Skip to content
OCM LABS

How to use Cloudflare development mode and analytics from the Magento admin

Turn Cloudflare development mode on before a theme deploy, run a quick purge and read Cloudflare analytics from the Magento admin with a free module.

Shane Blandford
Shane Blandford · FOUNDERPUBLISHED · 6 MIN READ

Most day-to-day Cloudflare work on a Magento store is small: switch development mode on before a theme deploy, purge a few URLs after a content change, check whether the cache hit ratio moved after a rule change. With OCM Labs Cloudflare, a free and open source Magento module, none of it needs a second tab logged into Cloudflare. This post walks the Overview and Analytics tabs at System > Cloudflare > Dashboard, plus the matching CLI commands.

It assumes the module is installed, the token is in place and the website is connected to a zone. If not, start with how to set up Cloudflare for Magento.

What the Overview tab shows

Open System > Cloudflare > Dashboard. It lands on the Overview tab for the selected website, and the top of the tab is a status block:

  • Connection status.
  • Zone name and plan.
  • Whether development mode is on.
  • The edge cache settings in force: enabled or not, and the edge TTL.

Below that sit three panels: development mode, quick purge and a Health summary. Opening the dashboard needs the OCMLabs_Cloudflare::dashboard ACL resource; the buttons on it are gated separately, so a role can look but not touch.

Step 1: turn on development mode before a theme deploy

Development mode stops Cloudflare caching for the zone for 3 hours. Use it when you are about to deploy CSS, JavaScript or template changes and want every request to reach the origin while you check the result, without purging over and over.

  1. On the Overview tab, find the Development mode panel.
  2. Turn it on. The status block updates to show development mode is on.
  3. Deploy the theme and check the storefront. Every request now goes to the origin.
  4. When you are done, turn it off. A checkbox on the way off offers to purge everything, so visitors do not get a page Cloudflare cached before the change. Tick it unless you have a reason to keep the old cache.

Cloudflare turns development mode off by itself after 3 hours, so a forgotten switch does not leave the zone uncached all weekend. A deploy window longer than that needs the switch flipped again.

The switch needs the OCMLabs_Cloudflare::settings_write ACL resource, and the API token needs Zone:Settings:Edit.

The same from the CLI

In a deploy script, use the command instead of the button:

bin/magento ocmlabs:cloudflare:dev-mode on --website=base
# deploy the theme
bin/magento ocmlabs:cloudflare:dev-mode off --website=base

--website is repeatable; leave it off and the command runs for every website with a zone configured. The CLI command only flips the switch, so follow the off with a purge for the same effect:

bin/magento ocmlabs:cloudflare:purge --all --website=base

Step 2: quick purge from the Overview tab

The Quick purge panel takes cache tags, URLs or prefixes, one per line, or purges everything for the selected website. Prefixes are host plus path, for example www.example.com/catalog.

Quick purges skip the queue and run immediately, so the result shows straight away. They still land in System > Cloudflare > Purge Log with the mode, item count, status and Cloudflare's request ID. The panel needs the OCMLabs_Cloudflare::purge ACL resource.

For how the queued purges work, the purge modes and the rate limits per plan, see how to purge Cloudflare cache from Magento.

Step 3: read the Health summary

The Health panel summarizes the last health run: pass, warn, fail and skip counts, and when it ran. It links to the Health tab for the full 25 checks with their evidence and fixes. Checks run hourly from cron, so a stale timestamp usually means cron is not running.

Step 4: check the same figures from the CLI

Everything in the Overview status block is available from the command line:

bin/magento ocmlabs:cloudflare:status

It prints, per website, the zone name and ID, the plan, development mode, whether edge caching is on and the edge TTL. Exit code 1 means a Cloudflare call failed or no listed website has a zone, so it doubles as a smoke test at the end of a deploy.

Step 5: read the Analytics tab

The Analytics tab reads Cloudflare's GraphQL Analytics API for the website's zone. Each panel loads on its own, so a failed query in one panel shows an error there and the rest of the tab still loads.

REQUESTSTotal requests in the range
CACHED REQUESTS / HIT RATIORequests Cloudflare served from the edge, and their share of the total
BANDWIDTH SERVED / SAVEDBytes served, and the bytes the origin did not have to send
UNIQUE VISITORSCloudflare's unique visitor count for the range
THREATS BLOCKEDRequests Cloudflare's security features stopped
ORIGIN RESPONSE P50 / P95Median and 95th percentile time the origin took to answer
REQUESTS AND CACHED REQUESTS OVER TIMEA line chart over the range
BANDWIDTH OVER TIMEA line chart over the range
STATUS CODESBreakdown by HTTP status
CACHE STATUSHit, Miss, Dynamic, Bypass and the rest, as Cloudflare reports them
TOP PATHSThe most requested paths with their cache status
TOP COUNTRIESThe ten countries sending the most requests
TOP USER AGENTSThe ten most common user agents

After an edge caching change, watch Cached requests / hit ratio and Top paths. A low hit ratio with checkout and account URLs at the top of the paths list is a bypass path doing its job, not a bug.

The Range selector

Cloudflare keeps analytics for longer on higher plans, so the Range selector only offers what the zone can answer:

FREE24 hours
PRO24 hours, 7 days
BUSINESS AND ENTERPRISE24 hours, 7 days, 30 days

The 24 hour range uses minute-level data; the 7 and 30 day ranges use daily data. Nothing in the module gates this; it is Cloudflare's retention per plan.

Step 6: tune the analytics cache and the warm-up cron

Analytics responses are cached in the ocmlabs_cloudflare cache type, so opening the dashboard several times in a row does not hit Cloudflare's API each time. Two settings control this, both at Stores > Configuration > OCMLabs > Cloudflare > Analytics, default scope:

ENABLE ANALYTICSYes
ANALYTICS CACHE TTL (SECONDS)900

A cron job runs every 15 minutes and warms the cache for each website's default range, which is why the tab usually opens with data already there. The 900 second default matches that interval. Raise the TTL and the tab shows older numbers; lower it and more dashboard opens become API calls.

Set Enable Analytics to No to hide the tab and stop the warm-up cron from fetching. The config paths for scripts:

bin/magento config:set ocmlabs_cloudflare/analytics/analytics_enabled 1
bin/magento config:set ocmlabs_cloudflare/analytics/analytics_cache_ttl 900

Step 7: fix an empty Analytics tab

If the tab is empty or shows an error, check these in order:

  1. The API token has Analytics:Read. Without it the tab reports the permission error Cloudflare returned.
  2. Enable Analytics is Yes.
  3. One panel errors while the rest load. Cloudflare changed a GraphQL field; the panel names the error and the other panels are unaffected. Report it.

With Debug Logging on, every API call is written to var/log/ocmlabs_cloudflare.log with the token redacted, which is the quickest way to see the exact error.

Where the charts come from

The charts are drawn with a vendored copy of Chart.js 4.4.1 that ships with the module. Nothing is loaded from a CDN, and the admin makes requests to your own Magento and Cloudflare's API and nobody else. That matters if your admin sits behind a content security policy or a network that blocks third-party hosts.

The full reference for both tabs is on the Dashboard & Analytics docs page.

If you would rather have someone set up Cloudflare in front of your Magento store and read the numbers with you, that is our performance and infrastructure work.

FAQ

How long does Cloudflare development mode stay on?+
Three hours. Cloudflare turns it off again by itself after that, whether you switched it on from the Magento dashboard, the CLI command or Cloudflare's own dashboard. A deploy that runs longer than that needs the switch flipped again.
Does turning development mode off purge the Cloudflare cache?+
Not on its own. The Magento dashboard offers a purge everything checkbox when you turn it off, and the CLI command does not, so in a deploy script follow the off command with a purge if you want visitors to see the new theme straight away.
Which Cloudflare plan do I need for 30 day analytics in the Magento admin?+
Business or Enterprise. The Free plan offers 24 hours, Pro adds 7 days, and Business and Enterprise add 30 days. The Range selector only lists the ranges the zone can answer. This is Cloudflare's retention per plan, not a limit in the module.
Why is the Analytics tab empty?+
Usually the API token is missing the Analytics:Read permission, or Enable Analytics is set to No under Stores > Configuration > OCMLabs > Cloudflare > Analytics. If only one panel shows an error, Cloudflare changed a GraphQL field and the rest of the tab is unaffected.
Does the dashboard call Cloudflare's API every time I open it?+
No. Analytics responses are cached in the ocmlabs_cloudflare cache type for the Analytics Cache TTL, 900 seconds by default, and a cron job warms that cache every 15 minutes for each website's default range. The tab usually opens with data already present.
Does the admin load any scripts from a CDN for the charts?+
No. The charts use a vendored copy of Chart.js 4.4.1 that ships with the module, and the admin makes requests only to your own Magento and Cloudflare's API.
Shane Blandford

Shane Blandford

FOUNDER

Founder of Orange Collar Media, a Denver ecommerce agency behind 800+ Magento and Shopify builds. In Magento since version 1.x - building, rescuing, and supporting revenue-critical stores since 2008.

All posts by Shane Blandford→

KEEP READING

Related from the Journal.

Your store can sell more. Let's find out how much.

Start a project