OCMLABS/MODULE-CLOUDFLARE · CLI REFERENCE

Command line reference for purging, status, development mode, health checks, cache rules and VCL export

  • Magento
  • Adobe Commerce
  • Hyvä

Every command that takes --website=<code> (-w) accepts it more than once. Without it, the command runs for every website that has a zone configured.

Exit codes

CodeMeaning
0Success
1A Cloudflare call failed, a health check failed, or no listed website has a zone. vcl:export returns 1 for any error
2Bad input (an invalid option combination or value)

ocmlabs:cloudflare:purge

Purge now, without the queue.

Terminal window
bin/magento ocmlabs:cloudflare:purge [--website=<code>]... (--all | --url=<url>... | --tag=<tag>... | --prefix=<prefix>...)
OptionNotes
--allPurge everything for the website’s zone. Cannot be combined with the others
--urlAbsolute http(s) URLs, repeatable
--tagCache tags, repeatable. Purges only the websites the tags belong to
--prefixHost plus path, for example www.example.com/catalog, repeatable

Exits 1 on any API failure. Each purge is written to the purge log with the trigger cli.

ocmlabs:cloudflare:status

Terminal window
bin/magento ocmlabs:cloudflare:status [--website=<code>]...

Prints, per website: zone name and ID, plan, development mode, whether edge caching is on and the edge TTL.

ocmlabs:cloudflare:dev-mode

Terminal window
bin/magento ocmlabs:cloudflare:dev-mode on|off [--website=<code>]...

Turns Cloudflare development mode on or off for the website’s zone. Cloudflare turns it off again after 3 hours. Needs Zone:Settings:Edit on the token.

ocmlabs:cloudflare:health

Terminal window
bin/magento ocmlabs:cloudflare:health [--website=<code>]... [--json]

Runs all 25 health checks and prints a table of status, check and message, or the full results as JSON with --json (status, message, fix and evidence per check). Exits 1 if any check fails, so it can gate a deploy or feed a monitor. The “Real visitor IP” check is skipped from the CLI because there is no Cloudflare request to inspect.

ocmlabs:cloudflare:rules:apply

Terminal window
bin/magento ocmlabs:cloudflare:rules:apply [--website=<code>]... [--dry-run]

Prints the diff between the zone’s current [OCMLabs] rules for the website and the recommended set (kept, added, changed, removed) and applies it. --dry-run prints the diff only. Rules the merchant wrote are never changed. Running it twice reports no changes the second time. Needs Zone:Cache Rules:Edit on the token.

ocmlabs:cloudflare:vcl:export

Terminal window
bin/magento ocmlabs:cloudflare:vcl:export [--varnish-version=4|5|6|7] [--output=<file>]

Prints Magento’s generated Varnish VCL with the Cloudflare changes, or writes it to a file with --output (-o). Default version is 6. Syntax-check the result with varnishd -C -f <file> before loading it. See Varnish.

Deploy pipeline example

Terminal window
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy
bin/magento cache:clean
bin/magento ocmlabs:cloudflare:rules:apply
bin/magento ocmlabs:cloudflare:purge --all
bin/magento ocmlabs:cloudflare:health --json > var/log/cloudflare-health.json

Queue consumer

Not a module command, but the one that sends queued purges:

Terminal window
bin/magento queue:consumers:start ocmlabsCloudflarePurge --max-messages=10000

See also

In this module