Have you ever published a post or made a CSS update and then gone to the homepage and it not be there? Moved from one tab to another to find out that you’re signed in when you thought you’d signed out? Chances are good that the culprit is your cache. Given that page speed is one of the biggest factors in ranking for search, using the cache to reduce server load for our scripts and images has become just about necessary. Unfortunately, when you’re dealing with any kind of cached assets, snags occur. We want to help you get them untangled by learning how to clear your WordPress cache.
What is a Cache?
Dealing with websites and browsers, the cache is the spot where pages, files, or other elements are stored in memory so they can be retrieved quickly. It might be in your browser, on the server hosting your website, or even a CDN’s server far, far away from everything else. But either way, those files are what’s served to your users rather than having to make a database query each time.
Here’s a simplified description. Keep in mind, however, that in reality, the web is more complicated than this. But the point’s the same.
Web servers and browsers use HTML instructions to build pages one at a time. They store the components for these pages in different locations. Without a cache, these pages will have to be built every time the server is asked for the page. Cache stores that page in memory to use over and over again. Kind of the same way that the printing press made it so that you didn’t have to write out whole books by hand whenever you wanted a new copy, if that makes sense.
Clearing the WordPress Cache
For a WordPress website there are three types of cache:
- Browser – a place on your computer or device where your browser stores the information about a website that doesn’t change often. Rather than downloading the same information every time you visit the website, the browser pulls the information from its memory. The web page loads faster and the network uses less data.
- Cache Plugin – a plugin designed specifically to deliver premade web pages, speeding up the time it takes to recreate the page from HTML instructions.
- Server Cache – using their own cache plugins or scripts your host might store premade web pages in memory to deliver to your visitors, reducing the load on the server.
A problem can occur when one or more types of cache don’t recognize when a website has updated or doesn’t consider that update significant enough to clear its memory and reload the page. This means that your users may not see new images, new updates, even new pages or posts because the caching software doesn’t hold it for one reason or another. As you can see from the list below, WP websites store the cache in several places. You might or might not need to clear them all, but we figure that you should know about them all so that you know how when the time comes.
Clearing Browser Cache
Let’s start with the browser cache. This is not only the easiest of the caches to clear (well, probably tied with most WP plugins), it is also the most common offender when it comes to you not seeing changes or updates to a site. However, this only clears your local browser cache. If this affects anyone else, clearing just your browser cache won’t help the issue. This is a personal fix.
If only you are affected, then you should clear your browsing data. Clearing the cache is different for each browser, but practically all of them have a cache clearing option in their options or settings. You should be able to hit a hamburger/three-dot icon for a dropdown menu, an options/preferences choice, and then find a search box and type in cache. That will bring you directly to the place where you can clear your browser’s cache.
If you only want to clear a single page’s cache within the browser, then you can press Shift – CMD – R on Mac or Shift – CTRL – R on Windows. Doing so will reload without using the cached files and will instead refresh them. This doesn’t clear the browser cache, just for this individual page.
Clearing Cache Plugin Data
If the problem persists on more than one browser or computer, then you should clear your WordPress cache plugin’s data. Caching plugins provide cached data to browsers. The browsers then don’t need to download files from the server every time someone requests the page. Even some security plugins that provide a firewall layer of protection will have caching capability.
If your website is hosted by a WordPress Managed hosting (WP Engine or Flywheel, for example), they might not allow caching plugins to install. If this is the case then they are providing this caching either via their own plugins or on the server-side, and it can be cleared there. They may or may not have a method to manually clear the WordPress cache. You’ll find a cache clear or flush button within your dashboard or from the top menu if that’s the case.
However, if they don’t, this is when you would contact their support team with the problem and let them sort it out. Which is good because if what errors show up are related to caching, they will be able to fix it and move you along. If it isn’t related to caching…well, the same thing applies. Either way, you see one of the benefits of managed hosting.
One of the top WordPress caching plugins is WP Rocket. It works well, it’s fast, and it is simple to access various features. Specifically here being the Clear Cache button.
All you have to do is navigate to the WP Rocket settings page, and right there on the main dashboard to the right is a button that says Clear Cache. Click it. Good job! You have cleared the cache.
W3 Total Cache
A lot of the caching plugins out there let you control each kind of caching that you can use within the browser. W3 Total Cache is one of these.
You can navigate to the page cache, object, database, browser, CDN, reverse proxy, and opcode caches, set each up like you want, and then you can simply click Save Settings and Purge Cache.
Even if you don’t make any changes, you can click the button to purge the cache. Works like magic.
WP Super Cache
The WP Super Cache plugin has a feature to delete cache manually or automatically. You can perform manual purge by clicking a button on its main Settings screen (in the Easy tab) called Delete Cache.
Under the Advanced tab, you will find two other settings you want to enable. The first is Clear all cache files when a post or page is published or updated. The plugin disables this setting by default. Keeping it enabled gets rid of the problem of needing to clear browser cache when you publish a new post. The second is Extra homepage checks.
(However, these do not stop the need for clearing it when you make adjustments or changes.)
Additionally the Advanced tab, you can also set the cache timeout settings.
This is a good option if the browser takes too long to recognize your updates.
WP Fastest Cache
You might also want to call WP Fastest Cache WP Simplest Cache. Because in terms of being able to clear the WordPress cache and make sure things are up and running as you need them, it couldn’t be any simpler.
All you need to do is go into the main WP Fastest Cache item in the dashboard, click on the Delete Cache tab, and you will see two large blue buttons. One will be labeled Delete Cache, which does exactly that. And the second is Delete Cache and Minified CSS/JS. If you’re truly having issues, getting rid of minified files, too, can help. The plugin regenerates them as it does its thing in the future, same as the cache itself.
Also, if you need timeout rules, you can set them all right here, too. Just press the Add New Rule button, and you can set the length of time that your site will wait before loading the page regardless of other caching settings.
Clearing Server Cache
It is possible that your host is using cache plugins on the server even without telling you. This is especially true if you’re using managed hosting as many use server-side caching, like we mentioned above. Server-side caching can include:
- HTML – WordPress stores your website’s components in different locations. When a web browser asks for a page, the server builds that page based on the HTML code. HTML caching stores these pages so browsers can reuse them. They do not have to then build the page from scratch every time.
- PHP – PHP pages have to be compiled in order to build the page. The pages are cached so the code doesn’t have to be compiled every time.
- MySQL – The database is queried for the same results every time someone visits your website. This caches the results until someone writes or updates a new post.
- Object – WordPress uses an object caching API to cache programmatic objects. This cache normally only lasts for one request. Caching the objects allows them to be reused.
Servers also run file-swapping, virtual file systems, firewalls, sitemaps, etc. The control you have over server-side caching will depend on your host. You may be able to clear it in your host’s options settings. You can check for these settings within your cPanel or admin panel for the hosting plan.
The important thing to know here, however, is that this is not done through WordPress.
If the setting isn’t provided, the host may clear it if you contact support and ask. Often, they will ask that you perform all other cache options first. That may help you track down the culprit for your issues, too. Some will provide an easy bypass solution for testing such as typing /?nocache=1 after your URL. Each host is different. In general, we recommend reading their documentation to see how the host handles server-side caching.
Many websites use a type of cache called reverse proxy. A reverse proxy is a server that retrieves resources on behalf of a client. It then returns them to the client as if they came from the proxy server, creating a shield for the framework.
If you’re using an HTTP reverse proxy such as Varnish then the cached version of your site will expire after a short time and your new content will display. You can adjust the time for the cache to expire in your provider’s settings. To purge the cache manually use a plugin such as Varnish HTTP Purge.
If you’re using a plugin such as Varnish Caching, you can adjust the settings of cache TTL (Time To Live) and purge the cash manually with the click of a button.
Content Delivery Network (CloudFlare)
If you’re using a CDN the process is basically the same with one caveat: it’s better not to purge the entire cache. The process itself will vary depending on your host. One popular CDN is CloudFlare. Some hosts such as SiteGround even give you access to the free version of Cloudflare with your account
Find your settings tab within your CDN settings, and find the Settings tab. You will then see a Cache Purge option with a Purge button to the right. Simply click it, and all of your site’s cached files will begin to purge and regenerate to clear up any issues that might have arisen.
Clearing your WordPress website’s cache is a common way to solve problems such as login issues, a web browser not responding or sluggish, and updates not displaying. You shouldn’t have any problems doing this, regardless of your caching methods. If you are uncomfortable with doing this for any reason, remember your host’s support team is there for you. No matter what you choose, you will soon have your website loading and displaying every change you make.
What are your favorite tools for clearing a WordPress cache?
Featured Image via Sentavio / shutterstock.com
The post How to Clear Your WordPress Cache: A Step by Step Guide appeared first on Elegant Themes Blog.