Caching

What is caching

Even wondered what actually is cache and how it works? Here is a real-life example.

Please calculate how much is 4342+543+53252+523523+5235*4343434/433+2323 and wrote the result on a paper. You will need minutes to calculate the result, but once calculated you can store on the paper. Now if we ask you the same question, you can give us the answer just by reading it from the paper. If we change the formula but not notify you about that, you will still give us the result from the paper. If we notify you, you will need to re-calculate the result.

Translated into WordPress lifecycle:

  1. PHP Execution -> Please calculate how much is 4342+543+53252+523523+5235*4343434/433+2323.
  2. The generated page is cached by Litespeed -> wrote the result on a paper.
  3. When a user is accessing your cached page -> Now if we ask you the same question, you can give us the answer just by reading it from the paper.
  4. Possible cache issue ->  If we change the formula but not notify you about that, you will still give us the result from the paper.
  5. Cache miss -> If we notify you, you will need to re-calculate the result.

Well now at least you know why not all plugins are compatible with the Litespeed cache or other caching plugins, that is point 4).

Caching layers

There are many factors on how to speed up the WordPress performance, but full page cache is the most important in terms of the speed of generating the page that your visitor requested. Page caches save time and resources, and they do so by storing the full content of dynamically-generated pages so that static copies may be served to the user. A page cache allows the server to bypass PHP and database queries altogether witch drastically reduces server CPU and memory usage and contributes to having a lower monthly bill.

Other than full page cache, there are also other caching types like OPcache and Object-Cache that can also drastically speed up the PHP execution time while CDN can drastically speed up the delivery time.

Litespeed cache

We recommend Litespeed cache as a full page cache for best performance and platform compatibility. Litespeed cache is far the fastest caching plugin, not because of the plugin code but how the Litespeed server serves the cached content. It is a server-side, tag-based, executed at an earlier HTTP request cycle while all other plugins use PHP or serving static content via rewrite rules.

OPcache

OPcache is very important and can drastically reduce the PHP execution time especially on sites with a lot of PHP files.

Object-Cache

We use APCu for Object-cache, the fastest possible in-process storage, eliminating the network latency. Object-Cache drastically reduces the MySQL queries and it is persistent storage for all next requests.

CDN

CDN is also working as a caching layer, check our guide about Google Cloud CDN.

Object-Cache compatibility

While the persistent object-cache can improve the PHP execution time, it is disabled by default because there are so many plugins not compatible with persistent object-cache.

Here is an example:

Plugin: Transients Manager v1.8

Description:

The plugin author is caching the “View All Transient page” but he does not clear the cache if you edit some transient cache entity, so even you make changes to a transient entity, the “View All Transit page” will still show the old values.

View All Transient source code:

Update transient source code:

Development Mode

Development mode disables OPcache, Object-Cache, CDN, Litespeed cache & Web Application Firewall regardless of their statuses. This option is recommended for development or debugging a possible issue. To enable the development mode, go to our Closte plugin page.

Development mode

When Development Mode is triggered, all caches are flushed except Google Cloud CDN.

Clear all caches

All caches can be cleared within the WordPress admin, from the top bar. Clicking on Litespeed icon will clear Litespeed cache while hovering over the Closte menu in the top bar will give you options to clear OPcache & Object-Cache or Google Cloud CDN.

Flush caches from WordPress admin

Also, you can completely clear all caches by going to the Site->Cache Invalidation page.

Is this useful for you