Skip to main content

How Does Caching Work?

A guide to Seravo's multi-layer caching architecture. Learn how the automatic cache works, how to optimize site performance, and how to manage caching via the CLI.

Updated in the last hour

At Seravo, we use a sophisticated multi-layer caching architecture. It is designed to be high-performance by default while remaining fully customizable for developers via HTTP headers.

Caching Basics

Caching stores data temporarily so subsequent requests are served instantly. The most critical layer is the HTTP cache, which handles the delivery of your website's content.

  • Browser Cache: Stored on the visitor's device. Use a "Hard Reload" (Ctrl+F5 / Shift+Cmd+R) to bypass.

  • Server Cache: Stored at Seravo. It renews automatically but can be cleared manually at any time.

Default Logic & Architecture

Seravo’s environment consists of multiple optimized layers: nginx (HTTP), Redis (Object cache), OPcache (PHP bytecode), and MariaDB (Database).

Unless overridden by your application's Cache-Control headers, nginx follows these defaults:

  • Success Requests (HTTP 200/206): Cached for 15 minutes.

  • Inactive Cleanup: Assets not requested for 60 minutes are cleared to save resources.

  • Developer Control: You can override any default by sending custom headers from WordPress or nginx to set longer durations or disable caching for sensitive pages.

Best Practices for Developers

Choosing the right caching strategy is essential for both site speed and server stability. Here are our recommendations:

  • Always Cache PHP (Full Page): PHP processing is resource-intensive. Without a cache, traffic spikes or minor DoS attacks can exhaust PHP workers and crash the site. Even a 1-minute cache is significantly better than none.

  • Short Expire > No-Cache: If you need fresh content, use a short TTL (e.g., 60s). This protects the origin server while keeping content current.

  • Never Disable OPcache: Some mistakenly disable it to see fresh data. However, OPcache caches code, not content. Disabling it only degrades performance.

  • Granular Timing: A professional strategy uses long cache times for static content and shorter times for dynamic endpoints.

Clearing and Bypassing the Cache

You can either clear the cache globally for all visitors or bypass it locally for your own testing. Purging (globally) is best after site updates, while local bypassing is ideal for active development without affecting other users' experience.

How to Purge

  • WordPress: Click the Purge Cache button in the top admin bar (clears nginx & Redis).

  • SSH (CLI): Use wp-purge-cache for the whole site or wp cache flush for Redis only.

How to Bypass for Testing

  1. Hard Refresh: Ctrl+F5 (Win) or Shift+Cmd+R (Mac).

  2. DevTools: Open Browser DevTools (F12) > Network > and check Disable cache (works only while DevTools is open).

  3. URL Parameters: Add a unique string to the URL, e.g., example.com/?cache=bypass. This is treated as a fresh request, so cache is bypassed.

  4. Incognito Mode: Ensures a clean session without existing cookies or local storage.

Did this answer your question?