How to Clear WordPress Cache Effectively?

Last updated - July 8, 2021

If you are reading this article with curiosity, you might have already come across the term ‘Cache’ or ‘Caching’. You might have heard about using Cache to speed up the website. And instances, where you need to clear your cache when your website is not responding properly.

In this article, I’ll discuss the following questions. What is Cache? What are the types of Cache? The advantages and disadvantages, and how to clear Cache on a WordPress site?

What is Cache?

A straightforward definition is that Cache is a static version of your web pages that are stored at the client or the server side. This static version helps to render the web content faster and present it to your visitors in no time.

How Does Cache work in WordPress?

When a user requests a WordPress web page (in simple words, accesses a WordPress website), the PHP compiles the code in the background and stores/retrieves the data from the database using MySQL queries. The data is then retrieved from the server in the form of HTML and is presented to the user.

This loop can be cut short if the previously generated data is a general content which will be requested by the user or by several users very often. The cache helps to store this data in the client’s browser or the server side, depending on where the caching is performed.

Hence, caching can be also defined as reusing the previously generated content to speed up future web page requests.

What are the Types of Cache?

Basically, there are three types of Cache with respect to WordPress:

  1. Client-side Cache
  2. Server-side Cache
  3. WordPress Plugin Cache

1. Client-side Cache

Also known as Browser Cache, these are fragments of data stored in the user’s web browser. When a user requests for a web page, the information is retrieved from the server and is presented to the user.

A copy of this data is stored in the user’s web browser in the form of Cache. When the user requests for the same information in the future, the information stored in Cache is presented to the user.

With this type of caching, the number of requests per page will reduce, hence saving considerable time for accessing the page multiple times.

But what if there is an update to the content?

When the content is updated, the user may not see the change immediately. This is because the cache still contains the old data and needs to request the server for the updated content. The process of updating the cache is called Purging the Cache. The old cache files are deleted and the new cache is generated with the updated content. In WordPress, the cache will be purged when a new post is published, an old post is updated, a comment is posted, etc.

When the user makes a web page request, the browser checks for the update in the form of ‘304 response code’. If there is no update, the response will be negative (no). Instead, ‘200 response code’ is made to use the Cached content.

2. Server-side Cache

Unlike client-side caching, server-side caching has several mechanisms involved.

a) Full page caching: At the server side, the HTML pages are divided or fragmented into small units in the form of headers, body content, footer and so on. When the page request is made, WordPress simply combines all the fragments and presents it to the user. This could be quite useful for WordPress sites that run WooCommerce stores, as the user can enter your site from a particular product page listed in the search results.

b) PHP Code recompilation: When the PHP compiled code is cached, the server saves the time and resource for recompiling the same code for the subsequent requests made by other users.

c) MySQL database query results: Everytime the PHP code executes, the data has to be stored or retrieved from the database, based on the MySQL query. With caching mechanism, the results of the executed query can be cached, and can be retrieved when the request is made.

d) Object caching: WordPress, by default, has an object caching API that is used to cache some programmatic objects. The object cache lasts only for the ongoing request.

The server-side caching mechanism is useful in sites with high web traffic, where a number of users are requesting for the same content.

When the web page is requested, the server caching mechanism combines all the HTML fragments with the previously compiled PHP result, the previously executed MySQL query result, and the associated objects. It then sends the response to the user in the HTML form as a complete, single page.

Some of the managed hosting providers, like WPEngine, have their own caching mechanism. If you are in a shared hosting service, the caching option is still available with limited advantage.

Also, different hosting services have their own way of enabling the cache.

3. WordPress Plugin Cache

WordPress plugin repository has plugins for every small customization for our site, including caching. Instead of the browser, the caching plugins generate cache data for your WordPress website.

Here are the top 3 WordPress caching plugins:

1) WP Super Cache

WordPress Cache | WP Super Cache plugin
WP Super Cache plugin

This plugin is developed by Automattic, the folks behind WordPress. The plugin offers to serve static HTML files to 99% of your website users. One thing that really caught my attention was that you can choose to not cache for some logged-in users. Based on the login status, custom cache can be generated.

In addition to caching, the plugin offers page compression, cache rebuild mechanism, and CDN support. You can even preload the post, categories, and tags. The plugin has over two million installs!

The plugin serves cache in three ways:

  1. Expert – The quickest method, requires technical knowledge to modify the .htaccess file of your WordPress website.
  2. Simple – The recommended method that does not require modification of the .htaccess file and rather provides ‘supercached’ files that keep parts of your page dynamic in the caching mode.
  3. WP-Cache caching – Most flexible option, but slower than the other two methods. This method is basically used for known (logged-in) users. This mode is always enabled and can be disabled as required.

Check out the complete list of features of the plugin.

2) WP Total Cache

WordPress Cache | W3 Total Cache plugin
W3 Total Cache plugin

WP Total Cache consists of a number of useful features resulting in over a million installs! It can cache search result pages, feeds, database and memory objects, minified/compressed website pages, blog post, scripts, and stylesheets.

Additionally, it also offers Accelerated Mobile Pages (AMP) support, Security Socket Layer (SSL) support and CDN integration to name a few. This plugin can be used for both shared hosting or dedicated server. The developers claim that it can improve your overall site performance by 10 times and can save up to 80% of your bandwidth. Why not try it yourself?

Check out the plugin.

3) WP Fastest Cache

WordPress Cache | WP Fastest Cache plugin
WP Fastest Cache plugin

The third one on our list is the WP Fastest Cache plugin. It is one of the most simple yet effective caching plugins. In addition to creating static HTML pages, the plugin offers cache timeout options for specific pages, preload caching, excluding pages and users for caching, and leverage browsing option, multiple language support to name a few.

The plugin has easy options to enable/disable caching for mobile devices and logged-in users. You can also disable emojis on your site.

It has over 600,000+ installs and has been one of the fastest growing caching plugins because of its offerings.

Check out the complete list of features of the plugin.

Additional mention

A special mention to Breeze plugin by Cloudways. The plugin combines performance, convenience, and simplicity in one powerful package. It is one of the useful plugins for your WordPress, WooCommerce or WordPress multi-site setup, and has the potential to grow faster.

WordPress Cache | Breeze -WordPress Cache Plugin
Breeze -WordPress Cache Plugin

Check out the plugin now.

Quick tip: If you have a faster web hosting service, you may not need a caching plugin.

Alternate Caching Technique

Minifying JavaScript and CSS files: If you have ever faced slow loading pages or missing content on web pages, you should know that a number of Javascript files are the real culprit. Instead of using a large number of scripts and style sheets, you could just minify (compress) multiple files into one single file. This saves a lot of time when a single call is made for every style sheet, image or script, instead of each individual call.

While most of the WordPress plugins offer the minifying process, you can do this at server or client as well.

Advantages of using Cache

  • During the course of the article, you already have noticed that in every step cache saves a lot of time. This is very useful if you are in shared web hosting.
  • Caching helps in improving responsiveness of the website, in turn, helping your site achieving better Page Rank in the Search Engine Results Pages (SERPs).
  • Less number of compilations and query executions means faster loading time and saving server memory.
  • It is one of the key components in optimizing your WordPress site.
  • Since static cache pages are smaller in size compared to their dynamic pages, it saves user’s bandwidth although by a fraction amount.

Disadvantages of using Cache

  • The capacity of the cache memory is very low. Hence, data more than the available capacity cannot be stored.
  • Too much of cache data can make the primary memory response slower.

How to effectively clear WordPress Cache?

There are three ways to clear cache with respect to WordPress:

  1. Clearing Cache in Browser
  2. WordPress Caching Plugins

1. Clearing Cache in Browser

This is a very common method to clear the cache. Every browser settings contain quick option to clear the cache data.

Following demonstration shows how to clear cache in different browsers:

For Google Chrome:

  • Open Google Chrome and click on the menu (three vertical dot icon) on the top right corner of the browser.
  • Next, click More Tools to reveal further settings and click on Clear browsing data… option, as shown in the screenshot below.
WordPress Cache | Google Chrome - Clear Browsing Data...
Google Chrome – Clear Browsing Data…
  • A pop-up window appears where you can check the data to be cleared. By default, Cached images and files option is checked. Finally, click on CLEAR DATA button to clear the cache data, as shown in the below screenshot.
WordPress Cache | Google Chrome - Clear Cache Data
Google Chrome – Clear Cache Data

For Mozilla Firefox:

  • Open Mozilla Firefox and click on the menu (breadcrumb icon) on the top right corner of the browser.
  • Click Options setting as shown in the screenshot below.
WordPress Cache | Mozilla Firefox - Menu Options
Mozilla Firefox – Menu Options
  • Next, click on Privacy and Security tab and scroll down to Cookies and Site Data settings. Click on Clear Data button, as shown in the below screenshot.
WordPress Cache | Mozilla Firefox - Cookies and Site Data
Mozilla Firefox – Cookies and Site Data
  • A pop-up window appears where you need to choose the type of data to be cleared. Tick the Cached Web Content checkbox and click on the Clear button to clear Cache data from your Mozilla Firefox browser, as shown in the screenshot below.
WordPress Cache | Mozilla Firefox - Clear Cached Web Content
Mozilla Firefox – Clear Cached Web Content

For Opera browser, read how to empty Cache in the Opera Help section.

For Safari, read How to clear Safari’s cache and cookies on Mac?

2. WordPress Caching Plugins

Follow the below steps to clear cache for the WordPress Caching plugins discussed in the earlier section of this article.

1) How to clear cache using WP Super Cache?

  • Go to Settings option in the WordPress admin menu and click on WP Super Cache. 
  • In the Easy tab settings, scroll down to find Delete Cached Pages settings.
  • Finally, click on Delete Cache button.

A sample screenshot of the WP Super Cache settings is shown below.

WordPress Cache | WP Super Cache - Delete Cache
WP Super Cache – Delete Cache

2) How to clear the cache using W3 Total Cache?

  • Click on Performance option in the WordPress admin menu to reach the plugin dashboard section.
  • Click on empty all cache to clear all cache, or if you want to clear other types of caches such as Memcached, opcode, disk cache, or want to update the media query string, click on the respective button.

Below is a sample screenshot of the W3 Total Cache settings.

WordPress Cache | W3 Total Cache - Empty All Caches
W3 Total Cache – Empty All Caches

3) How to clear the cache using WP Fastest Cache?

  • Click on WP Fastest Cache setting in the WordPress admin menu.
  • Next, move to Delete Cache tab and click on Delete Cache to delete all the cache data.
  • Or you can click on Delete Cache and Minified CSS/JS to delete all cache data and minified stylesheet and script files.

A sample screenshot of the WP Fastest Cache settings is shown below.

WordPress Cache | WP Fastest Cache - Delete Cache
WP Fastest Cache – Delete Cache

A useful Add-on plugin: Clear Cache for Me

While the caching plugins that I mentioned above can clear most of the cache, there are chances that the cache in your site may not be completely cleared. Cache data for widgets, customizer, contact form 7, menus, settings, gallery albums, etc might be not cleared properly. Hence in such case, you can use an add-on plugin called Clear Cache for Me.

Download the plugin.

Quick tip: Another great way to clear the cache is flushing your DNS data. You can read an article on How to Flush DNS Cache? to understand in detail.

Over to you…

Caching helps in speeding up your WordPress website by creating static versions of the dynamic pages of your website. While caching can be one of the aspects to optimize your website, it has its own share of cons. If your site has lots of dynamic content, the cache has to be updated very frequently. In my opinion, always give first preference to getting a faster hosting service, rest everything falls.

Clear your web browser cache as the first step in clearing your cache data. If you are using WordPress plugins for caching, they provide straightforward steps for clearing any cache generated by the plugin or otherwise.

That’s all folks!

For now, continue exploring LearnWoo.


Suggested read:

LEAVE A REPLY

Please enter your comment!
Please enter your name here