It is important to have a fast website in terms of both user experience and search results. In this article we will find out what caching is, how it can help to speed things up and two popular caching plugins for WordPress.
What Is Caching?
Caching is a kind of storing data for future uses. We are talking about caching data related to web sites, so these can be HTML, JS and CSS code, but images, fonts, and Flash files are also cacheable.
There are two reasons why we should use caching: to reduce latency (gain speed) and to reduce network traffic (amount of data loaded).
The speed of the website can be a critical factor for commercial websites like webshops or search engines like Google.
Cache is generally used both on the client side (browser) and on the server side.
On the web usually every content component has an expiration date and time, that dictates how long the application uses the old version. When this time expires the server and client will use a new version which has to be downloaded again.
Caching Strategy Tip
A good strategy for caching is to identify the most popular and / or largest sized data and apply caching to that first. After this you can go further and find more components to cache.
Disabling Browser Cache in HTML
With this code placed in the top of the head section you can turn off client side caching.
<meta http-equiv="cache-control" content="max-age=0" /> <meta http-equiv="cache-control" content="no-cache" /> <meta http-equiv="expires" content="0" /> <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" /> <meta http-equiv="pragma" content="no-cache" />
Disabling Server Side Cache in PHP
This little two liner code goes to the uppermost part of a PHP file.
<?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past ?>
Using a CDN
CDN stands for Content Delivery Network. Usually it consists of multiple servers in multiple geographical locations to handle content used by websites. It can be used to speed up the loading of external files like CSS, JS and images. There are both free and paid options if you want to use this kind of service.
The physical location of the CDN servers is very important. If your website is in Europe and the CDN you are using has only servers in Europe but an American user requests a page then it will be just as slow as if you didn't use CDN.
What Will Be Cached?
It depends on your plugin what will be cached. Some plugins offer only caching for back end (PHP, MySQL) and others can handle frontend as well (HTML, CSS, JS, images, fonts, etc.). Read the description of the plugin to learn which parts of the
webpage will be handled.
Static and Dynamic Content
Static content (front end) is usually regular files (CSS, JS, images, Flash files, fonts, etc.) on the server and handled using the simplest methods available to the web server. Dynamic content (back end) is always generated (generally from a database, eg. articles in the case of a blog) at the time of request to the page.
Web Server Support of Caching Components
You can also find the Apache guide useful to understand how it handles caching and requests as well.
Why Use These Two Plugins?
These two tools were downloaded more than 4 million times combined and have a healthy reputation as well. While WP Super Cache is a simpler plugin in terms of how many things you can set, the other one is like a monster, because it has got a couple of dozen features per category.
WP Super Cache
The description: "Very fast caching plugin for WordPress."
This plugin basically works as a page cache which means that it creates static HTML files. These files are stored and replaced again when the given time expires. WP Super Cache is based upon a plugin originally by Ricardo Galli Granada. The usage of the plugin is very simple: install, then go to the options page and set the desired cache time. It is important to know that dynamic content eg. within the sidebar, will be refreshed only when the cached pages are refreshed.
W3 Total Cache
The description: "The highest rated and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your site. Add browser, page, object and database caching as well as minify and content delivery network (CDN) to WordPress."
This tool has a broad range of settings for example: page caching, minifying, database cache, object cache, browser cache, CDN, Varnish, performance and security by Cloudflare. It even features debug mode for several settings and the user can export and import configuration files.
Several benefits of using this plugin according to the developers:
- improved search engine ranking
- increased visitor time on site
- optimized progressive render
- fewer HTTP transactions
- reduced document load time
- bandwidth savings
|WP Super Cache||W3 Total Cache|
|Downloads||3.4 million+||1.2 million+|
|Works Without Modifying Files||Yes||Yes|
|Tested Server Support||
|Plugin Homepage||by Donncha O Caoimh||by W3 Edge|
|Support Forum||WP Super Cache||W3 Total Cache|
|Number of Settings||Moderate||Very Many|
|Number of Developers||One||Several|
Which Plugin to Choose?
Both plugins offer several usable categories of caching. The user interface of W3 Total Cache looks nicer than WP Super Cache, but at the same time the options can be a bit overwhelming there. It is a good idea to install both tools, check all the options and decide what you need, but all in all I would stick to WP Super Cache to spend less time fiddling.
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.Update me weekly