In WordPress, a cache saves a copy of each page on a website the first time it is loaded and serves those files to repeat visitors. This can improve WordPress speed and performance by speeding up loading times.
Most web browsers also use caching to speed up your browsing. They cache recently viewed files on your computer. This means that if you revisit a web page, then the browser can display the files already stored on your computer rather than needing to download them again.
Browsers can also cache DNS information to speed up navigation to frequently visited websites.
You can use the links below to learn about the different types of caches:
What Is a WordPress Cache?
A WordPress cache stores a temporary copy of your website content. This reduces the load on your WordPress hosting servers and makes your website run faster.
Caching can make your WordPress website 2-5 times faster. But how does this work?
How Does Caching Improve WordPress Performance?
WordPress pages are dynamic, and this means that they need to be built on the fly every time someone visits them. This uses a lot of server resources and slows down loading times.
This process involves a lot of steps, such as running PHP scripts, retrieving content from a MySQL database, and more. WordPress uses this to generate the HTML content that visitors see.
You can learn more in our guide on how WordPress actually works behind the scenes.
So, how does WordPress caching speed up your website? Instead of dynamically generating HTML content each time, a copy of the page is saved to the cache after the first load. Repeat visitors will then see the pre-built page, which is much faster than generating it from scratch.
How to Add Caching to Your WordPress Website
How to Clear Your WordPress Cache
As you update your content, the pages in your WordPress cache may become out of date. This means that your visitors will not be seeing the most recent version of your content.
Caching plugins handle this by giving you control over when the cache expires, when it is cleaned up, and more.
However, there may be times when you wish to manually clear your WordPress cache to make sure that your visitors are seeing your latest updates.
You’ll find instructions for popular caching plugins and hosting providers in our guide on how to clear your cache in WordPress.
What Is a Browser Cache?
A browser cache is used by most modern web browsers to speed up page loading even further. When you visit a web page, it will save the static content, such as images and stylesheets, on your computer.
The next time you visit the web page, those files will be quickly loaded from your computer instead of being downloaded from the web server, which is slower.
How to Control the Browser Cache With Expires Headers
Like the WordPress cache, the files in your browser cache can become outdated. That’s why your browser will refresh the contents from time to time.
As a website owner, you can control how often your website data will be refreshed by the browser. You achieve this by adding expires headers to your .htaccess file.
Expires headers are rules that set an expiration date for each type of file stored in the browser cache, like this:
## EXPIRES HEADER CACHING ##
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 3 days"
## EXPIRES HEADER CACHING ##
Once the files expire, they will be reloaded from your server to give visitors the most recent version of the page.
How to Clear the Browser Cache
Users can also clear their browser cache for troubleshooting purposes or if they want to make sure they are seeing the most recent version of a website.
We offer step-by-step instructions in our guide on how to clear your browser cache in all major browsers.
What Is a DNS Cache?
DNS stands for Domain Name Server, and it is like an address book that contains the IP address associated with each website on the internet. You can learn more about DNS in our guide on how domain names work.
When you type in a website address like www.google.com, your web browser needs that site’s IP address so that it can direct you to the webpage you are looking for. To find this IP address, the browser must access an online DNS server.
Once your browser knows the IP address for a domain name, it saves that information in a local DNS cache on your computer. Next time, it will be able to navigate directly to the correct IP address without needing to look it up in an online DNS server.
How to Clear the DNS Cache
Like other types of cache, a DNS cache can become outdated.
In those cases, your website will become associated with a new IP address, but the DNS cache may still contain the old address.
When this happens, you can follow our instructions on how to clear your DNS cache. We show you how to do this on Windows, Mac, and Chrome.
We hope this article helped you learn more about cache in WordPress. You may also want to see our Additional Reading list below for related articles on useful WordPress tips, tricks, and ideas.
- How to Properly Install and Setup WP Rocket in WordPress
- 5 Best WordPress Caching Plugins to Speed Up Your Website (2024)
- The Ultimate Guide to Boost WordPress Speed & Performance
- How to Clear Your DNS Cache (Mac, Windows, Chrome)
- How to Install and Setup W3 Total Cache for Beginners
- How to Fix WordPress Website Not Updating Right Away
- How to Install and Setup WP Super Cache for Beginners
- How to Clear Your Browser Cache in All Major Browsers (Fast Way)
- How to Add Expires Headers in WordPress (2 Methods)
- How to Clear Your Cache in WordPress (Step by Step)