Journal

Cleared the cache. Nothing changed.

The purge says success. Visitors see last week's page. Why a page cache quietly stops deleting its own files, and the rule that keeps it from happening again.

“We cleared the cache and nothing changed.” We hear it most weeks. A headline is fixed in the editor, the cache is purged, and the old headline is still on the home page an hour later. The site is not broken. Nine times out of ten the cache plugin is quietly failing to delete files it no longer owns, and nobody told it to say so.

How a page cache works

A page cache on WordPress or Magento writes a finished HTML copy of each page to disk the first time someone requests it. The web server hands that file to the next visitor without touching PHP or the database at all. It is the single biggest performance win a content site can have, and it is why a busy site can survive a traffic spike on modest hardware.

The catch is that the cache is just files in a folder. Whoever created a file owns it, and only the owner, or root, can delete it.

Where it goes wrong

On a well-run server the web server process creates and deletes cache files under one unprivileged user. Everything agrees. Then someone with root access runs a cache clear from the command line, or a cron job runs as root, or a deployment script regenerates the cache as the wrong user. From that moment the cache folder holds files owned by root. The next time an editor hits “clear cache” in the admin, the plugin, running as the web user, tries to delete those files, fails, and carries on as if it succeeded. The editor sees a green tick. The visitor sees last week’s page.

We found exactly this on a publisher’s site that had become a daily complaint. Every purge from the admin reported success. The root cause was a single cache clear that had been run as root during an unrelated fix weeks earlier. One command, weeks of stale pages.

Why it is hard to spot

Most cache plugins do not report a failed delete. Some do not even check. The admin screen says the cache is empty, the file listing says otherwise, and the only way to see it is to log in to the server and look at who owns the files. Add a CDN in front and there is a second cache that may or may not have been purged, so the symptom moves around depending on where in the world you look from.

The fix, and the rule

The fix is mechanical: change ownership of the cache folder back to the web user, clear it properly once, and confirm the next purge actually empties the folder. Ten minutes.

The rule that prevents it coming back is the useful part. Cache operations run as the web user, always. Cron jobs that touch the cache run as the web user. Deployment scripts that warm or clear the cache run as the web user. Root is for the operating system, not for the application, and any command that starts with “just quickly, as root” on an application folder is the one that will cost a week.

What to check if this sounds familiar

  • Does a purge from the admin actually empty the cache folder? Count the files before and after. If the number does not move, the purge is failing silently.
  • Who owns the files in the cache folder? If any are owned by root, you have found it.
  • Is there a second cache? A CDN or a server-side cache in front of the application needs its own purge, and the two must be cleared in the right order.
  • What else runs as root on that server? Cron entries and deploy scripts are the usual suspects.

We keep the platforms we host on one user per site, with cache and cron under the same identity, so this class of problem cannot start. If your site has a cache nobody quite trusts, that is a hosting conversation we have had before.

Got a similar problem? Talk to us.

Start a project