Skip to content

WP Rocket not working or cache not clearing: fixes

Fix WP Rocket when a form fails, styles go missing, a slider stops working or the cache will not clear. Prove the cause with curl, then fix it.

If WP Rocket broke a form, stripped the styling off a template, left a slider dead until someone clicks, or refuses to clear its cache, you are in the right place. Most “WP Rocket broke our site” tickets are not WP Rocket misbehaving. They are one optimization applied to code that cannot survive it, or a purge aimed at the wrong cache layer. When the cache will not clear, the stale page usually comes from a different cache in front of WordPress, such as a CDN, a server cache or Cloudflare, so purging WP Rocket alone changes nothing. Two curl calls tell these cases apart. The steps below then give the order to switch features off so you find the culprit on the first pass, and the fix for each failure mode that comes up most often.

What you’ll accomplish

  • Prove in a single request whether WP Rocket is even in the path for the URL that is misbehaving.
  • Isolate which one optimization broke the page, in a fixed order, instead of toggling settings at random.
  • Read the cache directory directly, so “the cache did not clear” becomes a fact instead of a feeling, and purge the stack in an order that does not refill it with the stale HTML you just deleted.
  • Fix the failures behind most WP Rocket incidents: silent forms, stalled checkouts, leaked logged-in pages, styles lost to minification or Remove Unused CSS, dead sliders and add-to-cart buttons, 404s on CDN assets, a stale page after an edit, a runaway preload, a stripped .htaccess block, and a licence that will not validate.
  • End with a per-site exclusion list you can hand to the next person.

Prerequisites

  • WP Rocket 3.10 or newer on WordPress 6.0 or newer. Feature names moved between releases: “Remove Unused CSS” replaced the older “Optimize CSS delivery” toggle, “Delay JavaScript execution” became prominent in the 3.9 line, and the combine options were retired for sites that never enabled them. If a setting is not where this guide says, search the settings screen for the phrase rather than assuming the feature is gone.
  • WP Rocket is commercial software, licensed per site. An unvalidated or lapsed licence stops updates and the hosted parts of some features, so check it before blaming a setting.
  • Shell access with WP-CLI, or at minimum an admin account and a terminal that can run curl. The wp rocket subcommands ship with the plugin — no package to install.
  • A staging copy. Every fix below changes what real visitors receive, and two of them (the purge and the preload) generate load on the origin.
  • Knowledge of what sits in front of WordPress. With Cloudflare, LiteSpeed Cache, Varnish, or a host-level page cache in the path, several symptoms below are not WP Rocket’s. Some managed hosts run their own page cache and WP Rocket deliberately stands down on them, keeping only the optimizations — there, “the page cache does nothing” is intended.

How it works

WP Rocket is a page cache with an HTML, CSS, and JavaScript rewriter bolted on, and almost every incident belongs to exactly one of those two halves.

The page cache half runs from wp-content/advanced-cache.php, a WordPress drop-in that loads before the WordPress bootstrap finishes. If a cached file exists for the requested URL and no exclusion matches, that file is returned and WordPress itself never loads — which is why plugin-side debugging so often shows nothing at all.

The rewriter half runs at the other end, on the HTML WordPress just produced. Minified assets land in wp-content/cache/min/, generated critical CSS in wp-content/cache/critical-css/, and the per-page stylesheets from Remove Unused CSS in wp-content/cache/used-css/. Every “the styles are missing” and “the form does nothing” report starts in that second half.

Request flow through browser, CDN, server cache, and WP Rocket, showing the exclusion check, the disk cache lookup, and the point where a stale page survives a purge

That split gives three families of failure: a rewriter failure changes the HTML, so a curl response shows it; a page cache failure serves the right HTML at the wrong time, so cache files and timestamps show it; a layer failure is invisible in both, and surfaces only when you ask each layer what it is holding.

The consequence that matters: WP Rocket is the last cache in the chain, not the first. Clearing it does nothing for a page Cloudflare is still holding, and a fix that looks correct in a private browser window can still be broken for everyone behind an edge node that has not expired yet.

Step-by-step

  1. Reproduce the bug with WP Rocket bypassed. The ?nowprocket=1 query parameter tells the drop-in to skip the cache read, the cache write, and the optimizations for that one request — the closest thing WP Rocket has to a safe mode, and it changes no settings.
curl -s -o /dev/null -w 'status=%{http_code} time=%{time_total}\n' "https://www.example.com/checkout/?nowprocket=1"

Expected: something like status=200 time=1.284. A much slower time than the same URL without the parameter is the success signal — you are now measuring uncached WordPress. Load the same URL in a browser: if the bug is gone, WP Rocket is in the path. If it is still there, stop; the cause is elsewhere and no exclusion will help.

  1. Read what the server sent, not what the browser rendered. A browser adds its own cache, its extensions, and any service worker your stack installed. curl adds none of that, and it is the only view of which optimizations actually fired.
curl -s https://www.example.com/product/widget/ | grep -o 'wp-content/cache/[a-z-]*/' | sort -u

Expected: one line per active feature, such as wp-content/cache/min/ where assets were minified and wp-content/cache/used-css/ where Remove Unused CSS ran. An empty result on a visibly broken page points at the theme, not WP Rocket. Run it again with ?nowprocket=1 appended: it should return nothing. If it still lists cache paths, an edge cache is dropping the unknown query string before it reaches PHP, and step 1 cannot be trusted until that is fixed.

  1. Confirm whether the page was served from cache at all. A page WP Rocket served from disk ends with a signature HTML comment.
curl -s https://www.example.com/ | tail -c 300 | grep -i "wp rocket"

Expected on a cache hit: a line containing Performance optimized by WP Rocket, usually with the time the cache file was created. No output means the page did not come from the WP Rocket page cache — either an exclusion matched, or something upstream answered first.

  1. Check that the drop-ins are actually installed. Backup plugins, security scanners, and hasty migrations all remove them, and the symptom is a cache that appears to do nothing.
wp config get WP_CACHE
ls -l wp-content/advanced-cache.php wp-content/wp-cache-config.php

Expected: 1 from the first command, and two non-empty files from the second. A WP_CACHE that is missing or false, or an advanced-cache.php of 0 bytes, means nothing has been page-cached since.

  1. Regenerate the drop-ins if either one is wrong.
wp rocket regenerate --file=advanced-cache
wp rocket activate-cache

Expected: a Success: line from each command. activate-cache writes the WP_CACHE constant back into wp-config.php. Editing that define by hand works too, but only above the require_once that loads wp-settings.php — below that line it is read too late to matter.

  1. Read the cache directory instead of trusting the admin bar.
find wp-content/cache/wp-rocket -name 'index*.html' | wc -l
du -sh wp-content/cache/wp-rocket

Expected: a count in the hundreds or thousands on a warm site, and a size in the tens of megabytes. Files live at wp-content/cache/wp-rocket/<host>/<path>/index.html, with an index-https.html sibling and gzipped variants depending on settings. A count of 0 on a site with steady traffic means the write path is broken, not the purge.

  1. Purge from the top down when a page will not update. Every layer above WP Rocket refills from the layer below it, so purging WP Rocket first and Cloudflare second re-caches the stale HTML you were trying to remove. Walk these questions in order and stop at the first yes.

Decision tree for a WP Rocket cache that will not clear: missing drop-ins, unwritable cache directory, an upstream cache, starved WP-Cron, then WP Rocket itself

stat -c '%U %a' wp-content/cache wp-content/cache/wp-rocket

Expected: the PHP user and a mode that user can write to, for example www-data 755 on both lines. A directory owned by root, or left at 555 by a hardening script, produces exactly the “the purge button does nothing” report.

  1. Bisect the optimizations in a fixed order. Turn off one group, purge, reload the URL with curl, and stop at the first toggle that restores the page. Switching everything off and back on at random is how a two-hour incident becomes a two-day one.

Ordered bisection of WP Rocket optimizations: delay JavaScript, Remove Unused CSS, minify JavaScript, minify CSS, then LazyLoad and CDN, each with the symptom that points to it

Delay JavaScript execution goes first, because it changes when code runs rather than what it says, so anything that had to run before the visitor touched the page is broken. Remove Unused CSS second. Minify and combine JavaScript third, then Minify CSS. LazyLoad and CDN rewriting last, since their failures look like missing media rather than a broken page. Re-enable each option as you clear it.

  1. Write the exclusion, not the off switch. Each feature has its own field, and a rule in the wrong one does nothing. Excluded CSS Files governs minification; Excluded JavaScript Files governs minification and defer; the Delay JavaScript execution panel has its own exclusion list, confusingly labelled the same way. CSS Safelist governs Remove Unused CSS, Excluded images or iframes governs LazyLoad, Exclude files from CDN governs URL rewriting, and Never Cache URL(s) governs the page cache. Most take one pattern per line and a (.*) wildcard, so /wp-content/plugins/some-plugin/(.*).js covers a directory without listing every build artefact.

  2. Clear and rewarm once the exclusions are in.

wp rocket clean --confirm
wp rocket preload

Expected: a Success: line confirming the cache was cleared, then a message that the preload was triggered. Preload runs asynchronously through WordPress cron, so an immediate return is normal — the cache fills over the following minutes, which is what step 6 lets you watch.

Validate it works

Run these three against a URL you know was broken:

curl -s https://www.example.com/pricing/ | grep -c "Performance optimized by WP Rocket"
curl -s -o /dev/null -w 'cached=%{time_total}\n' https://www.example.com/pricing/
curl -s -o /dev/null -w 'bypassed=%{time_total}\n' "https://www.example.com/pricing/?nowprocket=1"

Expected: 1 from the first command, then a cached time well under half the bypassed time. If cached and bypassed are within a few milliseconds of each other, the page is not being cached at all and you are back at step 4.

Then confirm the behaviour that actually broke: submit the form, run a test checkout, click the slider and the add-to-cart button immediately rather than waiting for a delayed script, load the page logged out in a private window, and watch the console for 404s.

Finally, confirm the exclusions survived the purge, because a rule typed into the wrong field quietly disappears when settings reload:

wp option get wp_rocket_settings --format=json | tr ',' '\n' | grep -i -E 'reject_uri|delay_js|exclude'

Expected: your excluded paths and script handles listed back to you. If a rule you added is missing from that output, it went into a field that was never saved.

Troubleshooting

Contact Form 7, WPForms, or Gravity Forms submits and nothing happens. “Delay JavaScript execution” is holding the form’s script until an interaction the form was supposed to handle itself. Add contact-form-7, wpcf7, wpforms, and gforms to the delay exclusion list — not the File Optimization list of the same name, which governs minification and defer. Re-test with the console open; a wpcf7 is not defined error means you excluded the wrong handle.

Stripe or PayPal checkout flickers or stalls before the payment fields render. Same root cause, higher stakes. Exclude js.stripe.com, checkout.paypal.com, and paypal.com/sdk from JavaScript delay, and add /checkout/, /cart/, and /my-account/ to Never Cache (URLs). WooCommerce and Easy Digital Downloads pages are excluded automatically, but only if the plugin was active when WP Rocket generated its rules — a store added afterwards needs a settings save.

A slider, a mega menu, or an add-to-cart button does nothing on first click. Anything that must run on page load rather than on interaction — an auto-rotating carousel, a sticky header measuring its own height, a handler bound at DOMContentLoaded — is defeated by delayed JavaScript, because the first click is spent on the wake-up. Exclude the library’s filename from the delay list. Analytics falls into the same trap, never firing for a one-page visit.

Layout breaks after enabling minification or combine. Minification strips comments and whitespace, which is fatal to a stylesheet with an unclosed brace or a script missing a semicolon — and when files are combined, one bad file takes the bundle with it. Open the generated file under wp-content/cache/min/, find where it stops making sense, and add that source file to Excluded CSS Files or Excluded JavaScript Files. Already-minified vendor files are the usual culprits.

Remove Unused CSS breaks a template, or never finishes. Two failures under one label. If a template lost its styling, the scanner dropped a class it never saw, usually one injected by JavaScript or generated by a page builder at render time: add it to the CSS Safelist, then clear the used-CSS cache — those stylesheets are cached per URL and the old one is served until you do. If instead the queue never drains, check WP-Cron, then outbound HTTPS: some releases generate the used CSS through WP Rocket’s hosted service rather than locally.

A content edit does not show up on other pages. Saving a post purges that post, the home page, and the archives WordPress associates with it — not every page that mentions it. A hand-built landing page or a block listing recent posts keeps its old HTML until expiry. Add those URLs to Always Purge URL(s) instead of lowering the global cache lifespan.

Preload floods the origin, or never reaches the end. Preload crawls the sitemap, and that crawl is real traffic the origin answers while also serving visitors. Watch it on the server while it runs:

uptime

Expected: a load average in line with your normal peak. If it sits at several times the CPU count, narrow the sitemap the preloader reads, run it outside business hours, and turn off Preload Links, which fires an extra request for every link a visitor hovers. If nothing happens at all, confirm the sitemap returns 200, then check WP-Cron: preload, cache expiry, and used-CSS generation are scheduled jobs, so with DISABLE_WP_CRON set and no system cron replacing it, none of them run — our guide on replacing WP-Cron with system cron covers that.

Two page caches are running at once. WP Rocket on a LiteSpeed server with LSCache active, or on a host already running Varnish, means two stores of the same HTML with two purge buttons: a purge works, then the stale page returns when the other layer repopulates. Pick one — keep LSCache for delivery and use WP Rocket only for the optimizations, or disable the LiteSpeed cache module for that site.

The .htaccess block is missing or keeps coming back wrong. On Apache and LiteSpeed, WP Rocket maintains a block between # BEGIN WP Rocket and # END WP Rocket that sets compression and browser-cache headers. Security plugins and hardening scripts overwrite it; the symptom is uncompressed assets rather than a missing cache, since the cached HTML is delivered by advanced-cache.php in PHP.

grep -c 'BEGIN WP Rocket' .htaccess
wp rocket regenerate --file=htaccess

Expected: 1 from the first command if the block survived, 0 if something stripped it, then a Success: line from the second. On nginx there is no .htaccess; the equivalent headers belong in the server config.

404s or blocked fonts right after filling in the CDN field. WP Rocket rewrites asset URLs to the CNAME you entered; if that hostname is not a pull zone in front of your origin, every rewritten URL is a 404. Fonts that load but are blocked are a missing Access-Control-Allow-Origin header on the CDN, not a WP Rocket fault. Plugins emitting absolute URLs get rewritten twice — add their path to Exclude files from CDN, for example /wp-content/plugins/elementor/assets/.

Logged-in users see someone else’s page. Check that “Cache logged-in WordPress users” is off, then look for a reverse proxy stripping cookies before they reach PHP. Membership plugins that set their own session cookie need that cookie name added under Never Cache (Cookies); by default WP Rocket only recognises the standard wordpress_logged_in_ prefix. Treat this one as an incident, not a performance ticket.

The licence will not validate, or updates stopped arriving. WP Rocket checks its licence against wp-rocket.me, so a server that cannot make that outbound call reports an invalid key even when the key is fine. Test egress from the server itself:

curl -s -o /dev/null -w 'wp-rocket.me=%{http_code}\n' https://wp-rocket.me/

Expected: wp-rocket.me=200. A timeout, refused connection, or 403 means a firewall is in the way. If the call succeeds and the key is still refused, it is usually bound to more sites than the plan allows, or lapsed — a lapsed licence keeps the plugin running but stops updates, which is how sites drift onto releases the documentation no longer describes.

When this is the wrong approach

If the exclusion list keeps growing until half the site is bypassed, WP Rocket is not the problem — the theme and plugin stack is. Twenty excluded scripts and six never-cache URLs means you are paying a cache plugin to not cache. Fix the underlying code, or move to a stack where object caching and a properly configured edge do the work instead.

If you run Cloudflare APO, do not treat WP Rocket as the primary cache; the two have to be coordinated deliberately, and we cover that pairing in WP Rocket and Cloudflare coordination.

The official WP Rocket documentation is the authority on which field a given exclusion belongs in, and the WP-CLI command reference covers the WordPress-side commands used above.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.