Optimize & cache
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
The Performance group in a WordPress site’s shell is one page, Optimize & Cache
(/sites/:srv/:dom/cache): a per-URL cache table with a live cache monitor, a
Settings drawer for the cache, and an Optimize drawer for asset minification,
compression, bloat removal and database cleanup. The old /optimize URL redirects to
this page. WordPress-only, available on all plans. The same controls also appear
as the Cache and Optimize tabs of a WordPress site’s Manage drawer.
Warm the cache and purge a URL, step by step
Section titled “Warm the cache and purge a URL, step by step”The Cache page is a searchable table of your site’s URLs (from its sitemap) with a live cache monitor on the right.
- Open Cache. Each row shows a URL, its type (page/post/category/tag/author) and whether it’s currently Cached or Not cached, with the object’s age and size.
- Search for a URL or use Filters to narrow by Type or Status (All / Cached / Not cached).
- On a row, hit Warm to render and cache that page now, or Edge to purge it from Cloudflare. Tick several rows to purge them from the box or the edge in bulk.
- Watch the Cache monitor rail: the Warm ring shows how much of your sitemap is cached, alongside on-disk object count and size.
- To wipe everything, use Purge all in the monitor footer.
What else you can do
Section titled “What else you can do”Cache (the page itself)
Section titled “Cache (the page itself)”- Cache monitor rail — a live read of all four cache layers: Page cache (Nginx FastCGI — warm coverage, disk usage vs a 1 GB cap, logged-in caching), Object cache (Redis — keys, memory, DB), OPcache (PHP bytecode — memory, hit rate, cached scripts) and Edge (Cloudflare zone). Refresh metrics and Purge all live in the footer.
- Hit rate card — how many page requests were served from the cache in the last hour, 24 hours or 7 days (hit / miss / bypass), and why requests bypassed it: POST requests, wp-admin and login, cart and checkout pages, paths you excluded, logged-in visitors, visitors with a cart, recent commenters, tracking links, other query strings. A reason you can fix gets an inline hint: when tracking links bypass the cache, Turn on switches on Cache tracking links right there. Read from the site’s own access log (agent 0.2.161 or newer).
- Cache settings drawer (the Settings button) — enable/disable the page cache, purge a single URL, warm from the sitemap with live progress, schedule an auto-refresh (daily / every N hours), toggle caching for logged-in users, set the Cache lifetime (default 10 h), turn Cache tracking links on or off, and turn the Redis object cache on/off or flush it. The Last purge row shows when the page cache was last purged and whether it came from the panel or from WordPress.
- Auto-purge on publish — publishing, updating, unpublishing or trashing a post purges the post, the home page (and its page 2), the posts page, its category, tag and custom taxonomy archives, the author page, the date and post type archives and the feeds. WordPress queues the purge and the server applies it within a few seconds, also while the server is disconnected from MZPanel.
- Cache tracking links — visits whose query string only has tracking parameters
(
utm_*,fbclid,gclid,gbraid,wbraid,msclkid,mc_cid,mc_eid,_ga,_gl,yclid,igshid) are served from the cache as the page without the query. Any other query string (search, cart, preview) still bypasses the cache. On by default for new sites. - Reset OPcache — clears PHP’s compiled-bytecode cache. Useful after a deploy that didn’t pick up.
- Edge cache — when a Cloudflare connection covers the domain, purge specific
URLs from the CDN edge. On a Cloudflare-proxied site, auto-purge on publish also
purges the same URLs at Cloudflare (agent 0.2.161 or newer): the server reports what
it purged and MZPanel repeats it with your stored Cloudflare token, batched and
rate-limited. A full purge clears the site’s hostname (and
www.) only, never the whole zone. - Edge page cache — an opt-in switch that lets Cloudflare cache the site’s HTML, see below.
Cloudflare proxy (orange cloud)
Section titled “Cloudflare proxy (orange cloud)”The Cloudflare proxy switch at the top of the Manage drawer’s Cache tab (and in the
Edge & cache group of static, PHP and runtime sites) turns the orange cloud on or off for
the site’s apex and www. A, AAAA and CNAME records. It goes through the workspace’s
Cloudflare connection that owns the zone, the same as DNS & TLS; other records (mail,
other subdomains) are not touched.
- No connection covers the domain, or the zone has no apex/
www.record: the row shows the state from the server’s DNS lookup and a Manage in DNS & TLS link instead of a switch. - Turning the proxy off with “Cloudflare only” on. With the server’s Cloudflare only guard on, the server refuses every request that does not come through Cloudflare, so the site would go offline. The switch reads the guard first and, when it is on, asks to Turn both off: the guard first, then the proxy. When the guard can’t be read (agent offline, read failed), the proxy stays on and the reason is shown.
- Turning the proxy on is always allowed. Every plan.
Edge page cache (Cloudflare)
Section titled “Edge page cache (Cloudflare)”Cloudflare does not cache HTML by default, so every page view reaches your server. The Edge page cache group at the bottom of the Cache settings drawer turns it on for this domain. It is off by default and needs:
- a Cloudflare connection under DNS & TLS that covers the domain, with a token that also has Zone → Cache Rules → Edit (asked for only when you turn it on; without it the switch answers “The Cloudflare token cannot edit Cache Rules” with a Reconnect Cloudflare link — add the permission to the token in Cloudflare, or connect a new token);
- the domain’s DNS record proxied by Cloudflare (orange cloud), its
www.(if any) pointing at the same site, and no path routes on the domain (an app served under a path of the site is never guarded, so the switch refuses withpath_routes_present).
The server needs agent 0.2.164 or newer. Turning it on also updates the site’s MZPanel
WordPress bridge and adds a header to the site’s Nginx config that tells Cloudflare which
responses it may store (only plain 200 pages; never redirects, errors, responses that set a
cookie or are marked private, and never longer than the server’s own Cache lifetime, at most
10 h).
Turn on Cache pages at the edge. MZPanel writes one Cache Rule in the zone, tagged
[mzpanel:html-cache], that lists every domain of the zone you turned on (and its
www.). Cache Rules you made yourself are never changed. What is cached: anonymous HTTPS
GET/HEAD page views. What always skips the edge:
- any URL with a query string (search, filters,
add-to-cart, previews; your server still caches tracking links); - visitors with a WordPress login, password-post, comment, WooCommerce cart or session cookie, or a PHP session;
wp-admin,wp-json(REST API), any.phpURL (login, XML-RPC, cron), and the/cart/,/checkout/,/my-account/pages;- the site’s own Never-cache URLs (a pattern Cloudflare cannot match makes it skip every page of the site; the group then names it), and the shop’s real cart, checkout and account pages (also under translated names).
Cloudflare keeps only what the server marks cacheable, so redirects, error pages and anything not answered by WordPress itself never reach the edge cache. If the site or its server is deleted or moved, or the server’s agent is rolled back, MZPanel takes the domain out of the rule and purges it. Adding a never-cache URL also purges the pages Cloudflare already holds for the site.
Changing Separate mobile cache or Never-cache URLs updates the rule within seconds; a change
made with mz on the server is picked up within 6 hours (or with Re-apply the rule).
The rule follows your server’s cache headers, so a response that sets a cookie or says
private / no-store is never stored, and the MZPanel WordPress bridge marks every page
rendered for a logged-in user that way. Publishing purges the page on the domain and www. (and
for every device type when pages are cached by device). When the site keeps a Separate mobile cache,
the edge caches mobile and desktop pages apart too. Publishing purges the changed URLs at
the edge within seconds.
The group shows whether the rule is In place, Changed in the Cloudflare dashboard
or Missing (re-apply with the refresh button), when it was last applied, and offers
Purge whole zone — a last resort that drops everything Cloudflare cached for the zone,
including its other hostnames, at most once a minute. Turning the switch off removes the
domain from the rule and purges the domain and www. from the edge.
Optimize drawer
Section titled “Optimize drawer”- Performance overview — a Tuned score (how many optimizations are on), bundle count and bytes saved, plus a Measure button that snapshots live page weight (CSS/JS bytes + request count) straight from the box.
- Asset optimization — a master switch, then Minify CSS (tdewolff) and Minify JS (esbuild) into pre-built static bundles, with Rebuild bundles. New assets that pages start loading are minified by the server in the background every few minutes; you don’t need to press Rebuild for them.
- CSS & JS loading — Async CSS, Critical CSS (shown only for a site that already has it on: the rendering service it needs is not available yet), Defer JS, Delay JS until interaction, Lazy-load iframes, Serve WebP images, and Minify HTML.
- Remove bloat — strip Emojis, oEmbed, jQuery Migrate, XML-RPC, Pingback, RSD/WLW, Shortlink and REST-API discovery links.
- Brotli compression — pre-compress text assets to
.brat the Nginx vhost. - Database cleanup — Clean now (revisions, auto-drafts, trashed posts, spam
comments, expired transients +
OPTIMIZE TABLE) and an Auto-clean schedule (Off / Daily / Weekly).
How it works
Section titled “How it works”Both parts dispatch jobs to the site’s agent, which runs everything natively — no child plugin required for the cache/optimize engine itself.
| Area | Job | What the agent does |
|---|---|---|
| Cache status / monitor | wp.cache status / opcache-status | reads FastCGI cache state; probes OPcache |
| Warm / purge a URL | wp.cache warm / purge-url | renders or deletes that URL’s cache object |
| Purge all | wp.cache purge | clears the site’s FastCGI cache zone |
| URL table | wp.cache urls | lists sitemap URLs with per-URL cache state |
| Enable / schedule / logged-in | wp.cache enable / cron-set / loggedin-set | edits the vhost + refresh cron |
| Tracking links | wp.cache tracking-set | caches tracking-only queries under the bare URL (per-site list) |
| Hit rate, bypass reasons | wp.cache stats | reads a bounded tail of the site’s access log (window minutes, default 1440) |
| Object cache | wp.redis status / enable / flush | manages the Redis object-cache plugin |
| OPcache reset | wp.cache opcache-reset | invalidates this site’s scripts; scope: all resets the whole FPM master |
| Optimize status / config | wp.optimize status / set-config | reads engine state; writes the optimization config |
| Build assets | wp.optimize enable / rebuild / build | minifies + bundles CSS/JS to static files |
| Brotli / DB clean / report | wp.optimize server-tune / db-clean / report | edits the vhost; cleans the DB; measures page weight |
Page cache is Nginx FastCGI cache; warm coverage compares sitemap URLs
actually cached against the total. OPcache is read by executing a PHP probe
inside the site’s PHP-FPM worker — the agent prefers cgi-fcgi straight to the
pool’s unix socket, bypassing Nginx/TLS/Cloudflare so the reading is accurate even
on vhosts that redirect or allow-list Cloudflare IPs. Edge purge and Cloudflare
zone lookup go through the control plane’s DNS integration, not the agent.
Optimize config flips are optimistic and batched — flick several switches and they save as one write; the heavy rebuild is a separate explicit action. The engine minifies into static bundles served straight by Nginx, so there’s no per-request work.
CLI & automation
Section titled “CLI & automation”Every action maps to an mz command on the box — the same engine the dashboard
drives:
mz wp <domain> cache status --json # page/object cache statemz wp <domain> cache warm https://<domain>/path --json # warm one URLmz wp <domain> cache purge --json # purge the whole page cachemz wp <domain> optimize status --json # optimization posture + bundlesmz wp <domain> optimize db-clean --json # revisions/transients cleanupPass --json for machine output. See The mz CLI and the
command catalog.
Automate it (MCP / REST)
Section titled “Automate it (MCP / REST)”| Goal | MCP tool | Job kind |
|---|---|---|
| Cache status, purge, warm, OPcache reset | wp_cache (action: status|purge|warm|opcache-reset) | wp.cache |
| Per-URL warm/purge, schedule, logged-in caching | jobs_create | wp.cache with warm, purge-url, urls, enable, cron-set, loggedin-set |
| Cache tracking links on/off, custom parameter list | jobs_create | wp.cache with action: "tracking-set", enabled, optional params (e.g. ["utm_*","fbclid"]) |
| Last purge, queued purges | jobs_create | wp.cache status → last_purge, purge_queue |
| Hit rate and why requests bypass the cache | jobs_create | wp.cache with action: "stats", optional minutes (5-10080) → hit_rate, counts, reasons[] (reason, count, samples, fix) |
| Redis object cache | jobs_create | wp.redis (status, enable, flush) |
| Optimize config, bundles, Brotli, DB clean, page weight | jobs_create | wp.optimize (status, set-config, enable, rebuild, build, server-tune, db-clean, report) |
| Cloudflare edge purge | dns_edge_purge | control plane |
| Edge page cache status, on, off | dns_html_cache_get (verify=1 reads the rule), dns_html_cache_enable (domain, serverId), dns_html_cache_disable | control plane |
| Re-apply the edge rule after changing the mobile cache or never-cache URLs | dns_html_cache_sync | control plane |
| Purge everything Cloudflare cached for the zone | dns_html_cache_purge_zone | control plane |
wp.optimize is classified as a write even for its status action, so a read token
cannot run it. Call jobs_schema for the exact action enum and fields.
Gotchas & troubleshooting
Section titled “Gotchas & troubleshooting”- Cached pages keep old output until purged. Optimization rewrites run at PHP render time, but the page cache stores the rendered HTML. After changing Optimize settings, Purge all in the cache monitor to serve the new output.
- OPcache scope depends on isolation. Reset this site’s OPcache only clears this site’s scripts. A site on the shared PHP-FPM master shares OPcache with every site on the same PHP version, so Reset all sites on this PHP version affects all of them. An isolated site has its own OPcache, so that option is not shown.
- “Waiting for the server agent”. WordPress queued a purge that the server has not
applied for over a minute. The MZPanel agent on the server is not running; restart
it (
systemctl restart mzagent) and the queued purges are applied. - A page that reads a tracking parameter in PHP. A cached page does not run PHP, so
a page that prints UTM values into a form or sets a cookie from them shows the first
visitor’s values. Turn tracking caching off for that site, or set your own list
(
wp.cachetracking-setwithparams).ref(affiliate links) is not in the default list. - Existing sites get the new defaults. A WordPress site still on the old 1 h lifetime moves to 10 h when the server agent updates (auto-purge on publish keeps it fresh). Tracking links turn on the next time any cache setting is changed (or a certificate is issued). A custom lifetime is kept.
- “OPcache N/A” isn’t the same as off. If the FPM worker doesn’t respond, the monitor shows N/A and asks you to refresh, rather than falsely reporting “disabled.”
- Edge purge needs a Cloudflare connection. The Edge action and zone read only appear when a Cloudflare connection covers the domain; connect it under DNS & TLS first. Automatic edge purge on publish runs for sites created on a Cloudflare-proxied domain, and (agent 0.2.164) for domains proxied later through MZPanel’s DNS records or when the edge page cache is turned on.
- Edge page cache errors.
cf_cache_rules_scope: the token lacks Cache Rules → Edit.not_proxied: proxy the DNS record first.agent_update_required: update the agent to 0.2.164.edge_guard_missing: the site’s Nginx config was not made by MZPanel.bridge_outdated: the WordPress bridge could not be updated.cf_rule_limit: the zone has no free Cache Rule (Free plan: 10).html_cache_too_large: too many domains or never-cache URLs for one rule. - “Other” bypass reasons on an existing site. The cookie part of a bypass (logged in, cart) is logged once the site’s cache settings are changed after the agent update (any cache setting); until then those bypasses show as Other and the card says so. Cloudflare does not cache HTML by default, so the edge does not change the hit rate shown here, unless the Edge page cache is on: then the pages Cloudflare serves never reach the server and are not counted.
- Optimize needs a current agent. Older fleet agents lack the Optimize engine — the Optimize drawer then shows “needs a newer agent.” Update the server’s agent to enable it.
- The mzpanel-agent helper installs on first enable. Turning Optimize on installs the site’s helper if it isn’t present yet.
- Agent offline → read-only. The page and its drawers need the agent online; when it’s offline the site shell shows an “agent offline” banner and the pages are unavailable.
Related
Section titled “Related”- Site overview — the health cockpit, with a Cache quick action.
- The mz CLI — driving a site from the command line.
- Command catalog — every
mzcommand.