MilliCache: The WordPress Cache That Treats Invalidation Like a Database Problem

A look at how a pre-boot PHP hook, Redis-class memory stores, and flag-based rules turn WordPress page caching into a precise control system instead of a blunt purge machine.

9 min read • View on GitHub • More from MilliPress

A clockwork WordPress page system with a central cache ledger and many labeled pages hanging around it. One thread is pulled and only the matching pages unlock, while a small trapdoor underneath suggests the cache intercepts requests before the normal WordPress engine starts. The image explains that MilliCache is built around selective invalidation and early execution, not just faster storage.
MilliCache’s thesis is simple: the cache is not just a bucket of HTML, it is a labeled system of relationships.
Key Takeaways

WordPress Caching, But With Actual Selectivity

Most WordPress caches are fast until they are wrong. Then they become a cleanup problem, and cleanup is where simple systems get expensive. MilliCache starts from a different premise: cache entries should carry labels, and invalidation should target those labels instead of guessing at URLs.

That is why the project feels more systems-like than most caching plugins. It is not just serving HTML from memory. It is building a model of what a page depends on, then using that model to clear only what changed.

BackendCache unitInvalidation modelTypical scale targetStrengthLimitation
File cacheStatic HTML fileURL-level purgeSmall to mid sitesSimple and familiarHard to keep precise at scale
Redis-style page cacheStored responseKey or URL purgeTraffic-heavy sitesFast lookups in memoryCan still be blunt about dependencies
MilliCacheLabeled cache entryFlag-based selective invalidationHigh-traffic, multi-site, shared-cache setupsTargets related pages without clearing everythingMore moving parts than a basic file cache

The Pre-Boot Trapdoor

MilliCache’s most important execution detail is not glamorous: advanced-cache.php. WordPress loads that drop-in before the theme, before most plugins, and before the database-heavy parts of the request. That gives MilliCache a chance to answer with cached HTML and exit early.

The practical result is straightforward. The plugin can skip the cost of a normal WordPress bootstrap on a cache hit. The strategic result is bigger: the cache is not an afterthought bolted onto WordPress, it is a first responder inserted into the request path.

MilliCache’s speed comes from getting into the request early. Its precision comes from knowing exactly which cached objects share a dependency.

<?php
// advanced-cache.php
if (file_exists(__DIR__ . '/src/Engine.php')) {
    require_once __DIR__ . '/src/Engine.php';
    \MilliCache\Engine::instance()->start();
}

How the Engine Orchestrates the Request

Under the hood, Engine acts like a conductor. It wires together storage, request processing, and response processing, then keeps the hot path compact so the request can stay fast. The interesting part is not that the system is modular. The interesting part is that the hot path stays slim because the surrounding pieces are separated cleanly.

That separation matters in WordPress, where global state and side effects can make even simple behavior hard to reason about. A Loader class centralizes hook registration, which makes the plugin easier to test and easier to audit. You can see the design bias clearly: fewer scattered hooks, more controlled orchestration.

final class Engine {
    private static ?self $instance = null;

    public static function instance(): self {
        return self::$instance ??= new self();
    }

    public function start(): void {
        // Boot storage, request processor, response processor.
    }
}

Flags, Rules, and the Difference Between Purging and Understanding

This is the center of the project. MilliCache tags cached responses with flags such as post relationships, archive relationships, and custom labels. When content changes, it invalidates by label, not by guesswork. That turns a content update into a dependency event.

That distinction changes the whole mental model. A blunt cache says, "this URL is stale." MilliCache asks, "which cached responses depend on this fact?" That is why the system feels closer to dependency management than to cache flushing.

The rule engine pushes that idea further. Instead of burying behavior in nested conditionals, millirules lets caching logic be expressed declaratively. In other words, the system can decide what to cache, when to cache it, and when to clear it without turning the codebase into a maze of one-off exceptions.

A close-up board of labeled cache cards connected by thin lines. One card marked as a post is pulled out, and several dependent cards light up through the network of relationships. A small rule panel beside it shows structured caching conditions as chips, making the system feel like policy rather than a pile of if statements. The image explains how MilliCache uses flags and rules to target only the pages that actually depend on a change.
A single changed fact can affect many cached views, but only the views that actually depend on it.

What the Storage Layer Is Buying You

MilliCache wraps a Redis-compatible storage layer, and that choice is not just about speed. It supports TCP, TLS, and Unix socket connections, which means the same abstraction can work in local, secured, and shared deployment setups. It is doing infrastructure work, not just convenience work.

There is also a practical security story here. Credentials can be handled with encrypted settings, and persistent connections reduce repeated handshake overhead. The plugin is clearly designed for environments where cache misses are not the only thing you want to avoid.

MilliCache stores complete HTML pages in memory and serves them in milliseconds — without loading WordPress.

MilliCache GitHub README, Project Documentation · MilliPress/MilliCache README

That README line is doing a lot of work, and it is accurate about the architectural bet. Millisecond responses are not magic. They are the result of getting the request out of the WordPress runtime as early as possible, then backing that shortcut with a cache store that can actually absorb the traffic.

Why This Plugin Feels More Like Infrastructure Than a Plugin

The codebase looks disciplined in the ways that matter for a WordPress system expected to live in real deployments. Strict typing, tests, WP-CLI support, and dependency prefixing all point in the same direction: survive the chaos of WordPress without becoming chaotic yourself.

The Strauss prefixing choice is a good example. It prevents dependency collisions in a universe where other plugins may ship their own libraries. That sounds mundane until you remember how often WordPress sites become a stack of mutually suspicious packages. MilliCache is built to coexist, not just to work in isolation.

Project traitWhat it suggestsWhy it matters
Strict typing and static analysisThe code is meant to be reasoned aboutFewer hidden edge cases in the hot path
WP-CLI integrationOperations are part of the productAdmins can inspect and manage cache behavior without the UI
Dependency prefixingThe plugin expects a crowded ecosystemReduces collision risk with other WordPress extensions
Test stackBehavior is meant to be verifiedSafer changes in a performance-sensitive system

How MilliCache Differs From the Old Guard

Older caching tools solved real problems, and they still matter. But they mostly optimize the storage location of the cached page. MilliCache is trying to optimize the intelligence around the cache entry itself.

ProjectCache unitInvalidation modelTypical scale targetStrengthLimitation
Page Cache RedRedis-backed page responseKey or page purgeFast single-host setupsSimple and quick to deployLess explicit about dependency structure
CachifyStatic post or page outputStorage-layer purgeSmaller sites and simple deploymentsFlexible storage choicesNot built around selective cache intelligence
Cache EnablerStatic HTML fileFile invalidationLightweight sitesEasy disk-based cachingLimited precision for complex dependency graphs
MilliCacheLabeled cache entryFlag-based targeted invalidationShared-cache and high-traffic WordPressControls what changes ripple through the cacheRequires more operational thought

What This Says About Modern WordPress Performance

MilliCache is a sign that WordPress performance work is becoming more like systems design. The interesting questions are no longer just "How do I cache this page?" They are "When should this cache exist? What does it depend on? What should disappear when the content changes?"

That shift favors teams running high-traffic sites, multisite networks, and shared infrastructure. If you are operating at that level, blunt purge behavior is not a feature. It is debt. MilliCache is interesting because it treats that debt as the real problem and builds the cache around answering it.