New Aug 13, 2024

How to clear the WordPress cache

The Giants All from Envato Tuts+ Code View How to clear the WordPress cache on code.tutsplus.com

In this post, we’re going to briefly cover what the WordPress cache is along with 5 methods you can use (and when to use each) to clear your cache.

Caching is an integral process for the performance of a website. However, there are times when caching can cause problems for us. So knowing how to clear the WordPress cache, when to do it, and the different methods is just as important as understanding what caching does in the first place. 

Here are the 5 methods we’ll be covering:

What Is Caching? 

Caching refers to a process where information from a web page gets saved to a temporary storage location. When caching is enabled, the browser retrieves a copy of this saved data to quickly serve up the requested URL to the user’s screen.

This is important because, without caching enabled, visitors would have to wait for the web server to transmit all of the related HTTP requests (including text, media files, scripts, stylesheets, and more) to the browser. Web pages with dozens of assets and drawing on lots of resources would take far too long to load without the efficiency of caching.

While this process may still need to happen upon their first visit, subsequent visits to the same pages should load significantly faster thanks to the cached content.

Here’s a basic illustration of how a server handles HTTP requests from a browser without caching enabled:

An illustration demonstrates how a browser receives HTTP requests without caching enabledAn illustration demonstrates how a browser receives HTTP requests without caching enabledAn illustration demonstrates how a browser receives HTTP requests without caching enabled

Each asset and script represents an individual HTTP request. So the more content on a page there is and the more stuff that’s happening in the background, the longer it’s going to take for the server to deliver it and the browser to display the page. 

Here’s a basic illustration of how it looks when caching is enabled: 

An illustration that demonstrates how caching simplifies the transmission of a stored web page to the browserAn illustration that demonstrates how caching simplifies the transmission of a stored web page to the browserAn illustration that demonstrates how caching simplifies the transmission of a stored web page to the browser

It’s not always the case that every asset is stored in the cache (especially when it comes to dynamic content). Nor is it always the case that the browser is the resource with the cached copy of the web page. In some cases, it’s WordPress (and the web server) delivering a static HTML file to the browser. 

Regardless of where the cache lives, the process is greatly simplified and your web visitors reap the benefits.

Why You Might Need to Clear the WordPress Cache

While caching is super helpful for speeding up resource-heavy web pages, it can sometimes cause issues for us. 

For instance, let’s say you’ve made some edits to a web page. You open the preview from WordPress to see how it looks on the frontend of your site. However, nothing appears to have changed. This is likely because it’s stuck in the cache. 

This problem can also occur within certain plugins. Slider Revolution, for instance, has its own live editing and preview modes. However, if the older version of the design you’re working on gets stuck in the plugin’s cache, the preview may appear outdated. 

Caching is supposed to make the process of loading web pages in the browser more efficient. However, if the browser or your server don’t receive the message that the content has been updated, then you might end up seeing old data that’s stored in the cache.

How to Clear the WordPress Cache

So, the question becomes, how do you manage the cache in WordPress?

There are five methods you can use to clear the WordPress cache with a plugin and without a plugin. Let’s go through them one at a time along with the best use case for each. 

Method 1: Clear the Browser Cache

Let’s say you type your domain name into the browser and then nothing appears except for a vague 500 internal server error message. 

The first thing you’ll probably try is refreshing your screen. If that doesn’t work, then manually clearing your browser cache would be a good idea. This is something your hosting support will recommend as well if you still can’t access the site after troubleshooting the issue on the backend.

To clear your browser cache, open the Settings panel. In most browsers, it’s tucked away under a hamburger menu or kebab menu icon in the far-right corner. 

Here’s where it is in Brave:

To clear the browser cache, open up the Settings from under the hamburger menuTo clear the browser cache, open up the Settings from under the hamburger menuTo clear the browser cache, open up the Settings from under the hamburger menu

The Settings panel will usually load in a new tab. 

If it’s not obvious where the browsing history or caching settings are, use the search bar to find them by typing in “cache”.

Search for "cache" in your browser to locate your browsing history settingsSearch for "cache" in your browser to locate your browsing history settingsSearch for "cache" in your browser to locate your browsing history settings

Go to the Delete browsing data section. A pop-up or new screen will appear that allows you to select which actions you need. 

After clicking Delete browsing data, you’ll be able to clear the cacheAfter clicking Delete browsing data, you’ll be able to clear the cacheAfter clicking Delete browsing data, you’ll be able to clear the cache

Unselect Browsing history and Cookies and other site data. Keep Cached images and files selected. Then click Delete data. 

This will clear your browser cache. Return to your website to see if the page is restored or the new content is there. If not, you may want to try again after closing and reopening your browser.

Method 2: Clear the Cache With a WordPress Plugin

If you’ve encountered a problem with your website not reflecting the changes you’ve made in WordPress, then the best solution is to clear the cache with a WordPress performance plugin. LiteSpeed Cache, WP-Optimize, and WP Fastest Cache are the most popular and highest rated. 

Most of these performance plugins add a purge button to the WordPress toolbar. Regardless, I’m going to walk you through each of these top-rated solutions so you can see where all the cache clearing options are.

Clearing the WordPress Cache With LiteSpeed Cache Plugin

To clear the cache, located the LiteSpeed icon in the toolbar: 

When the LiteSpeed Cache plugin is installed, a LiteSpeed icon will appear in the WordPress toolbarWhen the LiteSpeed Cache plugin is installed, a LiteSpeed icon will appear in the WordPress toolbarWhen the LiteSpeed Cache plugin is installed, a LiteSpeed icon will appear in the WordPress toolbar

Hover over it and you’ll find settings to: 

  • Purge All
  • Purge All - LSCache
  • Purge All - CSS/JS Cache
  • Purge All - Opcode Cache
Under the LiteSpeed Cache toolbar icon, users will find various cache purging optionsUnder the LiteSpeed Cache toolbar icon, users will find various cache purging optionsUnder the LiteSpeed Cache toolbar icon, users will find various cache purging options

LSCache refers to purging the plugin’s server cache. CSS/JS refers to purging just the cached CSS and JavaScript. And OpCode refers to clearing the object caching, which stores database queries and is an optional setting. 

Clearing the WordPress Cache With WP-Optimize Plugin

With WP-Optimize caching enabled, there are two places where you can clear the WordPress cache. The first is in the toolbar. Click Purge cache to instantly clear it. 

When WP-Optimize is installed, a Purge cache button appears in the WordPress toolbarWhen WP-Optimize is installed, a Purge cache button appears in the WordPress toolbarWhen WP-Optimize is installed, a Purge cache button appears in the WordPress toolbar

The other place to do this is within the plugin screen. Locate WP-Optimize on the sidebar. Then go to the Cache screen. 

From the WP-Optimize Cache settings screen, users are able to purge the WordPress cacheFrom the WP-Optimize Cache settings screen, users are able to purge the WordPress cacheFrom the WP-Optimize Cache settings screen, users are able to purge the WordPress cache

Click the Purge cache button. It will tell you exactly how many files and bytes are about to be removed from the cache. 

Clearing the WordPress Cache with WP Fastest Cache

There are two places within this plugin to manage the WordPress cache. The first is the Delete Cache button in the toolbar. 

From here, you can: 

  • Clear All Cache
  • Delete Cache and Minified CSS/JS
  • Go to the settings
When WP Fastest Cache is installed, users can delete the cache from the link in the WordPress toolbarWhen WP Fastest Cache is installed, users can delete the cache from the link in the WordPress toolbarWhen WP Fastest Cache is installed, users can delete the cache from the link in the WordPress toolbar

From the plugin panel, you’ll be able to delete the entire cache plus any minified CSS and JavaScript you have. 

In the WP Fastest Cache plugin settings, go to the Delete Cache tab to clear the WordPress cacheIn the WP Fastest Cache plugin settings, go to the Delete Cache tab to clear the WordPress cacheIn the WP Fastest Cache plugin settings, go to the Delete Cache tab to clear the WordPress cache

With this plugin, if you clear only the cached files, it won’t include the minified CSS or JavaScript. So be sure to use the second cache clearing option to remove all the saved data from the server. 

Method 3: Clear the Cache From Your Firewall

If clearing the cache in your WordPress performance plugin doesn’t help, the next place to check is your firewall (if you have one installed). 

Sucuri Security is one such WordPress firewall plugin that will cache your pages. When content isn’t updating on the frontend, clearing the cache inside this plugin might help. 

To do this, locate Sucuri Security on the sidebar. Then go to the Clear Cache tab.

When the Sucuri firewall is enabled via the WordPress plugin, users can use the settings panel to clear the cacheWhen the Sucuri firewall is enabled via the WordPress plugin, users can use the settings panel to clear the cacheWhen the Sucuri firewall is enabled via the WordPress plugin, users can use the settings panel to clear the cache

Click the Clear Global Cache button at the bottom. Or if it’s just one page that you’re having problems with, enter the path into the field and then hit Clear Cache. 

Method 4: Clear the Cache From Your Web Hosting Account

Usually, clearing the cache inside of WordPress and/or your browser should be enough to fix whatever problem you’re experiencing. However, if there still seems to be a disconnect between the content in WordPress and what’s showing on your website, log into your hosting account. 

With SiteGround hosting, for instance, there’s a section under Site Tools called Speed. Within it, there’s a Caching tool. 

For the most part, you’ll use this tool to enable the following types of server caching: 

  • NGINX Direct Delivery
  • Dynamic Cache
  • Memcached
In the SiteGround Speed section, users can manage three types of caching for their WordPress siteIn the SiteGround Speed section, users can manage three types of caching for their WordPress siteIn the SiteGround Speed section, users can manage three types of caching for their WordPress site

You won’t be able to clear the NGINX cache. However, you can manage both the dynamic cache as well as memcached, which both cache dynamic content. 

To clear either of these caching settings, go to the respective tabs, hover over the Actions icon on the right, and select Flush Cache. 

SiteGround users are able to clear the dynamic cache and memcached from their hosting panelSiteGround users are able to clear the dynamic cache and memcached from their hosting panelSiteGround users are able to clear the dynamic cache and memcached from their hosting panel

When you’re done, return to your website to check that the issue has resolved. 

Method 5: Clear the Cache Using Your CDN

There’s one other place where your content may be getting stuck. And that would be your content delivery network (CDN). 

If you have a CDN enabled in your web hosting account, open it up and look for a setting that allows you to purge the cache. In SiteGround, for instance, this setting is under Site Tools > Speed > CDN.

Various WordPress security plugins as well as image optimization plugins include CDNs as well. If these CDNs are activated, open up your plugin to see if there’s an option to clear the cache from there.

Frequently Asked Questions About Clearing the WordPress Cache

Before wrapping up, let’s quickly address the most common questions and concerns when it comes to clearing the cache.

Is It Safe To Clear the Cache in WordPress?

Yes. Manually clearing the WordPress cache deletes data saved in a temporary location, not from your actual website or server. 

Eventually, all cached data gets cleared. WordPress caching plugins enable us to set an automated schedule for cache clearing or to define rules for when it should happen (like when a page has updated). When we manually clear it, we’re just doing it earlier than expected.

Where Are the Cache Settings in WordPress?

When you have a performance or caching plugin installed, there’s usually a Clear cache / Purge cache / Delete cache quick-action link in the top toolbar. 

You can also access these settings from within your caching plugin’s settings.

How Often Should You Clear the WordPress Cache?

The nice thing about using a WordPress caching plugin is that you can automate this process. How frequently this plugin clears the cache, however, depends on how frequently you update your content. 

For example, a small business website with a Home page, About page, some Services pages, and a Contact page won’t need the cache cleared frequently because the content won’t change much (if at all). If you can keep your server from having to reprocess the same files and content, that’s ideal. So you could probably get away with clearing the cache once every week or two.

On the other hand, let’s say you have an ecommerce site or a blog. New content is likely published daily or weekly. So your cache should be cleared at a similar interval. This will ensure that visitors always see the latest information on your site.

Conclusion 

Without caching, you’d have two choices:

You could create smaller web pages, resembling the basic HTML-based pages of Web 1.0. This would limit the amount of data your server would need to process and transmit browsers. Or you could keep on creating beautiful, modern web pages, but leave your visitors waiting far too long for them to load every time they visit them. 

It’s important to remember, though, that caching can cause some issues if it’s not cleared automatically or frequently enough. So understanding how to manage the WordPress cache and when and where to delete this stored data is critical. 

Scroll to top