How and When to Fully Clear all Caches

Introduction

A well configured caching adds different options to help you get the best result for your particular site.

Caching Levels

NGINX Direct Delivery File-Based Cache

When a page is loaded, it makes a copy of your static content – images, CSS, JavaScript, etc. and puts them into the server’s RAM. Next time your visitors load your webpage, the content is fetched directly from the server’s memory which is significantly faster than the server’s hard drive. Learn more about the NGINX Direct Delivery option.

Dynamic Cache

A full-page caching mechanism for non-static resources. It caches the HTML output created by the PHP code of the website application and prevents unnecessary database queries, processing of each page visit, and more. It highly improves your loading speed and the TTFB (time to first byte) of your pages. Learn more about the Dynamic Cache option.

Memcached

An object caching mechanism designed to improve the connection between your application and its database. It greatly improves the loading speed of dynamic content that can’t be served by the dynamic Caching (checkout pages, dashboards and backends, etc). Learn more about the Memcached.

Drop-Ins

image of Drop-Ins
Those single files replace or enhance WordPress features in ways that are not possible for traditional plugins. Having both drop-ins is recommended. The advanced-cache.php file is created when the File-Based Caching is activated, while the object-cache.php file is created when the Memcached is activated.

CDN Cache

The content delivery network speeds up your website when you have geographically dispersed traffic across multiple countries and continents. The tool will cache your website content and will distribute it over multiple CDN data centers around the world. When someone visits your site the content will be delivered from the server closest to the visitor. Learn more about the CDN configuration.

PHP OPcache

A caching engine built into PHP that stores cached files in the root folder of the hosting account. OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request. More about the OPcache.

When to Clear Caches? How Often?

Automatic Purge

  • Perform a smart cache purge based on events happening on your WordPress site.
  • Adjust the WordPress API cache to purge too when clearing the cache.

Manual Purge

  • Use this option when you’re modifying content and don’t have automatic purge enabled to make sure that old cached is purged right away.
  • Flushing the Memcached cache can be done after making updates on the site or if something happens to the service (for example if it crashes, if that happens the object-cache.php file in the wp-content folder will be automatically renamed).
  • Clear all caches following a WordPress version update.
  • Clearing the OPcache periodically is recommend because it can keep obsolete files. It is a must when upgrading your PHP version used, otherwise every few months should be sufficient.

How and Where to Clear Each Different Cache?

In WP Admin

If you use SG Speed Optimizer plugin, you can:

  • schedule automatic purges and/or execute manual purges. Both options only do a smart purge.
  • click “Purge SG Cache” in the top admin bar menu. That button does a full purge (Advanced, File-based and Object caches) for the site.

In SG Site Tools

  • Speed > Caching > Dynamic Cache > Flush
  • Speed > Caching > MemCached > Flush
  • Speed > CDN > Cache Purge > Flush

And for the .OP Cache

  1. SG Site Tools > Devs > SSH Keys Manager > create a private ssh-rsa type key.
  2. Save your SSH user and logins credentials.
  3. Download PuTTY software.
  4. Use PuTTYgen to convert your SSH key in a DSA type .ppk format.
  5. Use Pageant to load your key.
  6. Use PuTTY to login > copy and paste the code below to clean the cache
    rm -rf ~/.opcache/
  7. Full tutorial.

Leave a Comment, Share Your Thoughts!