# CloudFlare Cache Cleaner

> Purge CloudFlare cache directly from Magento 2 CLI — by URL, tag, host, or prefix

Managing CloudFlare cache alongside Magento deployments usually means switching to the CloudFlare dashboard or writing custom API scripts. This module brings cache purging directly into Magento's CLI, so you can clear caches as part of your deployment pipeline without leaving the terminal.

Particularly useful for stores that use CloudFlare as a CDN and need granular cache invalidation — not just "purge everything" but targeted purging by URL patterns, cache tags, hostnames, or URL prefixes.

**GitHub:** [qoliber/m2-cloudflare-cache-cleaner](https://github.com/qoliber/m2-cloudflare-cache-cleaner)

## Installation

```bash
composer require qoliber/module-cloudflare-cache
bin/magento setup:upgrade
```

Requires Composer 2.x. Works immediately after installation — just configure your CloudFlare API credentials in the Magento admin.

## Purge Methods

| Method | Use case |
|--------|----------|
| **By URL/file** | Purge specific product pages, category pages, or CMS pages after content updates |
| **By tag** | Purge all pages sharing a cache tag (e.g. all pages showing a specific product) |
| **By host** | Purge an entire subdomain or hostname — useful for multi-store setups |
| **By prefix** | Purge all URLs under a path (e.g. `/catalog/` or `/checkout/`) |

## Integration with Deployments

Add cache purging to your deployment scripts:

```bash
# After deploying new static content
bin/magento cloudflare:cache:purge --by-prefix="/static/"

# After CMS content update
bin/magento cloudflare:cache:purge --by-url="https://store.com/about-us"

# Nuclear option — purge everything
bin/magento cloudflare:cache:purge --all
```
