Connect a Shopclass site to Cloudflare: purge changed pages automatically, install the recommended cache rules, and view cache analytics — all from the admin.
Automatic cache purge. When a listing is created, edited, deleted, or changes state (enabled/disabled, activated, made premium, expiry changed), and when a category or static page changes, the plugin purges the affected URLs at Cloudflare: the item's own page (per enabled locale), the home page, the item's category listing, the seller's public profile, and the sitemap index. All URLs are derived from core helpers — nothing about your site's structure is hardcoded.
Purges are immediate and best-effort; anything that fails (a Cloudflare blip, an expired token) is queued and retried on the hourly cron, so a purge is never lost and a listing save is never blocked.
Search and filter result URLs are not purged — they are unbounded and can't be enumerated, so they rely on whatever TTL your cache rules give them.
Cache rules. One click installs three rules in your zone's cache phase:
- cache public pages, respecting the origin's
Cache-Control; - bypass the admin (
/oc-admin/*); - bypass any request carrying a login/personalization cookie.
The cookie list comes from core (osc_cache_relevant_cookies()), so it stays
correct across versions. The plugin touches only the rules it created — your other
rules are preserved — and it is safe by construction: a page the app marks
private, no-store is never cached.
Cache lifetime. Optionally set how long Cloudflare's edge keeps each page, per page
type — item, static, and listings (home/search/category). Sent as a Cloudflare-CDN-Cache-Control
header, so only Cloudflare holds the longer copy while the origin micro-cache keeps its short,
self-healing TTL (the origin has no invalidation; only the edge is purged). Off by default; a
longer item TTL is safe because purge-on-change clears the edge — so it relies on cache purge
working.
Analytics. A read-only widget shows the last 24h cache hit ratio, requests, and bandwidth served from cache.
- Shopclass 6.2.0+ (uses the core caching contract and
osc_cache_relevant_cookies()). - PHP 8.0+.
- A Cloudflare account with the site as a zone.
- Create a zone-scoped Cloudflare API token with these permissions:
- Cache Purge — Edit
- Cache Rules — Edit
- Analytics — Read
- Zone — Read
- In admin, open Settings → Cloudflare, paste the token, and Save.
- Click Discover zone to fill the Zone ID from your site domain (or paste it), then Test connection.
- Click Install / update cache rules.
To clear the whole cache after a deploy that changes site-wide markup:
php oc-content/plugins/cloudflare/bin/purge.phpIt reads the same saved credentials and purges everything.
The plugin stores only your API token and Zone ID (in the site's preferences) and talks solely to the Cloudflare API over HTTPS. It sends no analytics or telemetry anywhere else.
GPL-3.0-or-later. See LICENSE.
