WordPress website caching: How it is done in 2020
Every single person in this world hates slow loading websites. Especially, if you have a website with a huge number of visitors every single month, you are going to lose a lot of traffic. Further, you will also eventually lose ranking as Google doesn’t like a slow website. The solution for this is to speed up your website. You can implement WordPress caching to speed up your website.
You surely need a reliable host, faster CDN, and things like that to speed up your website. However, even if you have all these things, the loading time might still below. You can do website caching to increase the speed. Let’s understand more about it and how you should do WordPress caching in 2020.
So, what is the website caching?
You probably are wondering what is website caching and how it will speed up your website, right?
So, let’s understand it by an example.
Basically, when you open a website, this is how it works.
- You type in the URL and open a website.
- The browser sends a request to the server. This is known as the HTTP request
- Thereafter, the server collects all the resources from the page and displays it as the webpage
Website caching is a process where all the collected data is saved in the WordPress cache memory. So, if you do the cache of the website, it will add one more step in the process.
Assuming you enable the cache of website, the new steps will be as follows
- When you type the URL and open a website, the browser calls the server
- Now, the browser will send the request to the server.
- The server will look for the previously fetched page from the cache memory. If there is a page (which is not updated), the server will send that page instead of loading the resources again. This will decrease the loading time and hence increase the speed of your website.
Types of website caching
There are two types of website caching which you can use. One of them is full webpage caching which is also known as full caching and the other is object caching.
Full-page caching is a concept where the entire web page is stored in the cache memory, it will then load the page from the cache memory instead of sending the complete request again. This is helpful when you have a huge number of visitors on your website coming every single day.
You surely don’t want to load the entire page for every visitor out there. Instead, you can directly display the page from the cache of the website. If you have more cache pages, your website will ultimately load faster.
There is one another concept in object caching. It is known as fragment caching. Fragment caching is where you only store some elements as the cache of the website. This can be a widget, image, and stuff like that.
Browser caching vs server caching (website caching)
Now, when it comes to caching, there are mainly two types of caching. One is where your browser will store the cache of the website. The other place is where your server will store the cache of the website.
In order to get the maximum speed for your website, you need to implement both of them effectively. Even though browser caching is a thing which you can’t control much but you can surely a couple of things to make it the best. Let’s directly jump into how to do WordPress caching.
How to do browser caching effectively?
As mentioned, you surely can’t control many things when it comes to browser caching but you can surely do a couple of things to optimize cache pages on the user’s side.
The first thing that is not only useful in browser caching but also useful in WordPress caching. You need to compress images. There are many optimizing plugins available that you can use to compress your images.
Compressing these images will ultimately speed up your website and the cached pages will also be able to save more data. As a result, you will get faster loading time and better search rankings.
There are many ways you can compress your image. One of the best ways to compress your images is by using the smushing plugin. It will automatically smush or compress the image whenever you upload a new image. This might seem like a small step but eventually, it will help you a lot in increasing the loading speed. Further, you can add lazy loading to your images. This will only load images when the user scrolls. In simpler words, let’s say your web page has 20 images. Lazy loading will only load the first image. When the user starts scrolling, the lazy loading will then load the rest of the images.
You can use the Smush plugin to do these things.
The plugin helps you compress the images in bulk.
HTTP cache control
You can control the HTTP cache by telling the browser about it. For that, you will need to open your WordPress home directory from your file manager. Head over to .htaccess file and hit the edit button.
You can add the following code at the last line (after #End WordPress)
Header set Cache-Control "max-age=84600, public"
It basically tells the browser that you need to save the following kind of files for 84600 seconds.
You can then set the expiry headers. For that, you can add the following code to your .htaccess file as mentioned on the above page.
## 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 2 days"
## EXPIRES HEADER CACHING ##
You also need to disable Etag. Etag automatically tells the browser which files you need to store as cache pages. As we are optimizing the cache of website on browser-side too, you will need to disable the default tags.
For that, you can again head over to .htaccess file in the WordPress directory. Hit the edit button and add the following code at the end of the file.
# TN - BEGIN Turn ETags Off
# TN - END Turn ETags Off
How to do WordPress caching from the server-side?
Now that you know how you can leverage the power of browser-side cache pages; it is time to do WordPress caching from the server-side. Both of them are equally important, so you need to do both of these things if you truly want to speed up your website.
WordPress is an amazing CMS because of the plugins. So, we are going to install any ONE of the cache plugins. Please note that you shouldn’t install more than one cache plugins as it might misbehave and clash with each other. As a result, your loading time will not increase and chances are it might even crash your website.
You can surely try the plugins one by one. So, we are going to see a couple of plugins that you can use to leverage the power of server caching.
The best part is that the plugin comes with a default configuration. So, you don’t need to spend your valuable time in configuring the plugin. You will be able to do it with ease. All you have to do is just activate the plugin. Further, if you want, you can surely set the options and configure the plugin according to your needs.
One of the most popular WordPress cache plugins available in the free plugin directory is W3 total cache. It has more than 1 million downloads and loved by most of the people out there. The star ratings of this plugin are also amazing.
Basically, this plugin works the same. It will minify some of the scripts and save the page with all the other cache pages of your website. Whenever the user loads the page, the server will first show the cached version of the page. Hence, the website will load way faster than the original speed.
#3 Wp Optimize
The next one is the WP optimize plugins. Rather than being only the WordPress cache plugin, it is an all in one plugin that you can use for your website. It can clean your database, compress heavily sized images, and can also cache pages of your website. The plugin will do almost all the things that you need to speed up your website.
Cleaning your database will reduce the requests and hence decreasing the load time. It also compresses the images. Hence, the image will load faster. You can do all these things from a single plugin which is a great thing. You will need a bit configuration though before you can start using this WordPress cache plugin.
Why you should store WordPress Cache?
Now, we are going to see some of the advantages of website caching. This will give you a clear idea of why you should store a cache of the website.
- Your website will load faster as the page will load from the cache pages
- WordPress caching will also help you in ranking as Google considers loading time as one of the most important factors in ranking.
- It gives amazing user experience as they don’t need to wait
- Further, it will decrease HTTP request and hence causing lesser load on the server
Things to keep in mind
Along with this, there are a couple of things that you should keep in mind if you are doing website caching.
- If you are using managed hosting, there are chances that your host might already be using one of the cache tools. Hence, they will not allow you to use one of these WordPress cache plugins for the cache. So, make sure you check the list of prohibited plugins.
- WordPress caching plugins are good only if you use one at a time. Using multiple website caching plugins will cause site failures and might also increase the loading time instead of decreasing it.
- If you have a website with more followers, you should consider going with the premium WordPress caching plugins. Most of the cache plugins also have a premium version you can try.
- Further, if you have a website with few visitors, you can also go with the object caching instead of full-page caching.
- Cache pages will expire when the cache memory limit is crossed or when it expires. However, browser-side cache memory will depend on the user. If they clear the memory, the cache pages will disappear.
- Last but not least, you should deactivate the plugin when you are developing your website. As you are constantly updating the theme or plugin, the webpage might show the wrong results (as it shows the cache pages) and you will have to purge all cache of the website every now and then.
To conclude, this was all about website caching. You can use the WordPress caching plugins to optimize the caching. Along with optimizing the cache of the website, also make sure that you implement Browser cache effectively. Once again, make sure that you are only using one plugin at a time. Further, there will be an option to Purge all cache which will clear all the cache pages’ memory, you can do it when necessary. Check out our list of 40 Fastest WordPress themes and see our guide on how to improve WordPress performance.
WEBSITE UP TO DATE & SECURE WordPress Maintenance Service
Save 17% with our Annual pricing plan.