Skip to content

How Cache Manager Auto-Detects the Best Backend

·

Most cache plugins assume you have Redis. Or they require manual configuration. Cache Manager takes a different approach: it detects what is available and picks the best option automatically.

The detection chain

On activation, the plugin scans your PHP environment:

Volatile cache priority:
1. Redis (if ext-redis + connection works)
2. Memcached (if ext-memcached + connection works)
3. APCu (if ext-apcu + CLI-safe)
4. RuntimeArrayStore (always, per-request only)

Persistent store priority:
1. SQLite WAL (if ext-sqlite3)
2. DBA/LMDB (if ext-dba + lmdb handler)
3. FileSegmentStore (always works)

Serializer priority:
1. Igbinary (fastest, smallest)
2. Msgpack (fast, portable)
3. PHP serialize (fallback)

Why SQLite for persistence?

Cache history, file change tracking, and trace data need to survive restarts. MySQL is overkill for plugin-internal metadata. SQLite WAL mode gives us crash-safe writes with zero configuration and no external dependencies.

The debug-url command

When something is not caching correctly, run:

$ wp gratis-cache debug-url https://your-site.com/

── Theme ──
  Active: gratis-theme 1.0.0
  theme.json: ae485385

── Object Cache ──
  Drop-in: Gratis/VLT (Redis)
  Redis: connected (1.07M used, 847 keys)
  alloptions cached: yes (HIT)

── Patterns & Templates ──
  Patterns registered: 35
  Gratis patterns: 29

Every cache layer is inspected: object cache, OPcache, page cache headers, file changes, and integration metadata from theme and builder.

Share this post: