Command line reference for purging, status, development mode, health checks, cache rules and VCL export
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
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | A Cloudflare call failed, a health check failed, or no listed website has a zone. vcl:export returns 1 for any error |
| 2 | Bad input (an invalid option combination or value) |
ocmlabs:cloudflare:purge
Purge now, without the queue.
bin/magento ocmlabs:cloudflare:purge [--website=<code>]... (--all | --url=<url>... | --tag=<tag>... | --prefix=<prefix>...)| Option | Notes |
|---|---|
--all | Purge everything for the website’s zone. Cannot be combined with the others |
--url | Absolute http(s) URLs, repeatable |
--tag | Cache tags, repeatable. Purges only the websites the tags belong to |
--prefix | Host plus path, for example www.example.com/, repeatable |
Exits 1 on any API failure. Each purge is written to the purge log with the trigger cli.
ocmlabs:cloudflare:status
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
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
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
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
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
bin/magento setup:upgradebin/magento setup:di:compilebin/magento setup:static-content:deploybin/magento cache:cleanbin/magento ocmlabs:cloudflare:rules:applybin/magento ocmlabs:cloudflare:purge --allbin/magento ocmlabs:cloudflare:health --json > var/log/cloudflare-health.jsonQueue consumer
Not a module command, but the one that sends queued purges:
bin/magento queue:consumers:start ocmlabsCloudflarePurge --max-messages=10000