WordPress Super Cache plugin, we use the browser cache. How to set up WordPress caching? Where is the cache time in WordPress?

I hope there is no need to explain to anyone why a caching plugin is needed and how important it is to choose one that will really help and not just create an extra load on the database with its presence. When analyzing, we will take into account all indicators, not just loading time.

The benefits of caching

A small digression. If anyone still doubts the need for caching, then know that from April 21, Google announced that all mobile-friendly sites (and speed is one of the components of “friendly”) receive a significant advantage in search results. Google's intentions are very clear - SEO specialists and webmasters need to work on both desktop and desktop performance. mobile version site.

There are several ways to improve the performance of your site and reduce its loading time, but for most beginner (and not only) optimizers, caching plugins are not one of, but the only tool used to achieve their goal.

WordPress generates pages dynamically, which leads to a large number of queries to the database. Caching dynamically generated pages allows users to see regular HTML pages, which significantly reduces page load time and reduces server load.

Caching Test Details

At the very beginning, it was planned to use 2 themes in the tests - the simplest “twenty-fourteen” and a more complex one (which would imitate a “real” site). But during tests it turned out that the effect of caching on the loading speed of the “twenty-fourteen” theme is so minimal that it can be neglected. It turned out to be more important fine tuning servers, but today’s article is not about that.

We will end up using only 1 theme (the Novelty theme from Tesla Themes). The test page is designed using graphics and text. There is also a sidebar and several plugins (news, feed from Twitter/Instagram). Hosting used from WP Dev Shed. As a result, we received a page with relatively big time downloads.

Because the site is new, it had no traffic (including, during testing, there were not even PS bots). The server worked in conjunction with Apache+ Ngnix.

The following plugins participated in the test:

  1. AIO Cache
  2. WP Fast Cache
  3. WP-Cache.Com
  4. Alpha Cache
  5. Flexicache
  6. Bodi0's Easy Cache
  7. Hyper Cache
  8. Hyper Cache Extended
  9. Cachify
  10. Lite Cache
  11. Next Level Cache
  12. Really Static
  13. Super Static Cache
  14. W3 Total Cache
  15. Gator Cache
  16. Wordfence Falcon
  17. WP Fastest Cache
  18. WP Rocket
  19. WP Super Cache
  20. Zen Cache (formerly Quick Cache)

The following remained for the test:

Brutal Cache - did not work;

Batcache is a plugin with a dependency on Memcache, which was not used in the current test.

Autoptimize and Widget Cache were also left out, because... they are not independent plugins, but support for others.

Benchmarking tools

We used services from Google, GTMetrix and Yahoo as tools. Thanks to this, not only page loading speed was tested, but also:

  • image optimization;
  • minification and optimization of js and css code;
  • use of browser caching;
  • server time delay;
  • use of Gzip compression;
  • placement of scripts;
  • number of HTTP requests.
  • use of CDN, parallelization/domain sharding;

Google PageSpeed ​​Insights

The site is checked both from the point of view of the desktop PC and from the mobile device. The result is given on a 100-point scale. The service is easy to use, but provides a relatively crude result that does not provide a full understanding of everything that can be improved.

GTMetrix and YSlow

Based on Yahoo's performance improvement guide. Again a 100 point scale is used. Services work with more than 50 different metrics. GTMetrix even visualizes the data in a waterfall chart of the loading process. In our opinion, this is one of the the best tools to identify ways to improve site performance.

Timing

The following tools were used to determine page loading speed and check server performance under load:

ApacheBench

Serves to determine the load on the site, calculates maximum amount requests per second. During the test, 1000 requests were sent across 10 different threads. The test was carried out 10 times. The best result for each plugin was recorded.

A very well-known website monitoring and testing service. 20 tests were carried out with each plugin and the best result was recorded.

Simple but useful service, showing the time it takes for the page to fully load in your browser. This is not a server-side tool, but a service that runs locally. We chose the download method via Ethernet, Opera browser. Each page was downloaded 101 times, with the average download time recorded.

So, let's start testing.

Google, GTMetrix and Yslow

The result of testing website pages using the specified services:

As you can see from the table, some plugins did not perform well here - the score is the same or very close to the score without caching. Google gave Super cache the best rating (for both desktop and mobile). In GTmetrix and Yslow, Fastest Cache and Rocket showed the best results. As we have already said, the rating from Google is less informative, because... it uses fewer factors in its evaluation.

So, the best plugins were WP Super Cache, WP Fastest Cache, and WP Rocket Cache.

Timing

Evaluation scores mainly indicate the quality of a site's code. This gives an understanding of what can be done to speed up the site. However, high ratings for a site do not mean that it loads faster than others. And this is the main mistake - evaluation tools give an abundance of ideas for improving the site to reduce loading time, but at the same time the loading time itself is practically not taken into account. Below is a clear example (screenshot from Pingdom).

The page earned 96 out of 100 points (this is better than 99% of pages on any site). At the same time, the page loads in about 35 seconds. This is what blind optimization can lead to.

Timing is a very important test because... Real measurements of page loading speed are carried out.

ApacheBench

Let's determine the maximum number of requests per second that our server can support. The higher the number, the better.

The best result was shown by WP Rocket. Second and third places were shared by WP-Cache.com and WP Fastest Cache.

The result without caching is 2.78 seconds. All plugins were able to improve this indicator.

The undisputed leader is again WPRocket. Super Cache is the second, W3 Total Cache is the third.

Here we decided to display not only the average, but also the median test result.

Average loading time

The situation is similar to the previous test. The top three have not changed - WPRocket, WPSuperCache and W3 TotalCache.

Median loading time

The leader is still WP Rocket, but at the same time, the practically unknown WP-Cache.com again shows a very good result.

Not caching alone

Of course, not everything depends only on caching. The choice of the Apache+Nginx combination, the correct server settings and its type (dedicated, VPS, shared), the quantity and quality (optimization) of images and much more play a role.

Conclusion

All presented plugins have different functionality. Some are indecently simple, while others can be compared to a Swiss army knife. Super Cache, W3 and other similar plugins are often used in their work by professionals who are familiar with CDN and other tricks. Other users (especially beginners) opt for simpler plugins (Lite Cache or WP-Cache.com). By the way, WP-Cache.com, despite its little-known status, was able to show excellent results.

Which WordPress plugin does caching better?

In first place (by a wide margin) is WP-Rocket. It has many advantages, but there is one BUT (for many this will be a disadvantage) - it is paid. The developers want $39 for it (and the updates are not life-time, but only for a year)

In second place (although considering how free it is, it can also be put in first place) is WPSuperCache. The results are almost the same as those of the leader, but he is absolutely free!

In third place is WP-cache.com. The only confusing thing is that it was last updated in 2014.

But it is simple, free and shows decent results.

It's been a while since Google announced that the speed at which a site loads will affect rankings. The same applies to mobile devices. But what you should be most concerned about is how a slow site will affect users. For example, are you aware that half of website visitors on the Internet believe that a website should load in two seconds or less? I think this is quite fair, because if you think about it, there is nothing more annoying than watching something load. Not to mention the inconvenience that a person experiences when he wants to buy something, but the site is slow.

Luckily, there are many ways you can speed up your website. One of best options is to use a special module for caching (cache). Today we'll take a quick look at what caching is and why it's so critical when it comes to page loading speed. Apart from this, I will also share with you a list of the best cache plugins on the market.

What is cache?

A cache is a place in computer memory where data is stored for future use. For example, instead of completely carrying out the process of loading a site from a database, part of the data is downloaded from the cache. When a visitor walks through your site, the site requests data from a database that is stored on the hosting. More specifically, they request images, Javascript, and CSS of your site so that it is in readable HTML files and delivered directly to the browser. Unfortunately, this process requires certain resources and takes time. However, there is no need for site users to run this process every time. Especially when it comes to static content on your site. For example, published posts that are unlikely to be edited by anyone.

This is why caching your site is necessary if you want to:

  • quickly provide access to site data that rarely changes
  • speed up the entire site loading process
  • provide a better user experience for all visitors to your site
  • promote in search engine rankings thanks to higher download rates
  • save server resources and reduce the number of crashes

As you can see, there are a ton of benefits to caching your WordPress site.

The main functionality that is included in each of the mentioned plugins:

  • caching for mobile users
  • file size reduction and GZIP compression
  • setting up a cache cleaning schedule
  • HTTPS/SSL support

Best WordPress Caching Plugins

Knowing that site speed is very important, and that it directly depends on caching, our next step is to add the appropriate plugin to our site. Here are some of the most reliable, affordable, and feature-rich solutions.

Today I invite you to discuss such an interesting topic as caching in WordPress. First of all, you need to clarify What is caching and why is it needed? Every blogger and webmaster rightly wants his blog or website to work quickly. As you know, WP does not have record high performance, so often even good hosting unable to compensate for this. But if you have “heavy” content, and even high traffic, it can be a disaster. In any case, there is an opportunity to speed up the blog, why not do it?

The WordPress engine, as mentioned above, is heavy by nature. It's all about its "dynamism". Unlike “static” platforms, WP runs on PHP, which makes numerous requests to the data bases, due to which the content is actually generated. Fortunately, there is a technology that can significantly speed up the process, it is called caching.

Caching principle basically quite simple. Usually it all comes down to the fact that one or another plugin generates static pages from dynamic pages, subsequently displaying them to the visitor. In this case, the server does not have to process most of the requests, which significantly reduces the load on the server and increases speed. Now let's get down to business. What caching plugins are there and which one should you choose? An excellent study conducted on Tutorial9 will help us with this, and I want to give you an excerpt from the results.

How was this research conducted? Apache Benchmark was used to evaluate the performance of a particular plugin. This test generates a large number of requests, based on which a report is generated on the number of requests processed by the server per second and the average data transfer time. Initial data: WordPress 2.9.1 with several popular plugins installed - Akismet, All in SEO Pack and Google XML Sitemap. The amount of traffic on the test blog is not large; mixed content is presented - text, images, spreadsheets, java scripts. For objectivity, each measurement was repeated several times a day.

I will not give the test results of all the plugins that were tested by the authors of Tutorial9, because it makes sense to focus only on the most common, popular and popular plugins. So let's get started:

Blog with caching turned off
A blog without activated plugins showed the following results:

Requests per second - 13.96;
Time for each request - 716.58 ms;
Data transfer rate - 673.98 Kbps

As you can see, the initial data is not impressive. Let's see what and how we can improve.

If you attract an audience from social networks, which can generate a very large amount of traffic, you cannot cope without caching. By the way, there is such an inexpensive service https://avi1.ru/ for the development and promotion of accounts, groups, communities and meetings in the most recognizable and passable in social networks. With its help you can get a large number of likes, views, subscribers and comments.

The popular WP-Cache plugin showed the following results:

Requests per second - 109.59;
Time for each request - 91.25 ms;
Data transfer rate - 5307.00 Kbps

Noticeably better than without caching. The result outperforms a blog without activated plugins by an average of 685%. I note that WP-Cache is a long-known plugin that has historically been popular.

WP Super Cache Plugin

WP Super Cache is currently perhaps more popular than WP-Cache. This is easy to explain - WP Super Cache is a modified version of WP-Cache. In addition to being faster, it is also “smarter”, that is, it can do more than its predecessor. In particular, it is easier to install and remove, it can clean up “garbage” after deactivation, and so on.

As for speed, the result is as follows:

Requests per second - 118.23;
Time for each request - 84.58 ms;
Data transfer rate - 5743.07 Kbps

Test results are superior to WP-Cache results. WP Super Cache is on average 747% faster than a blog without caching enabled. I would like to note one more feature - if in WP Super Cachecompression enabled, it may even be slower than a blog without plugins!

Hyper Cache plugin

Hyper Cache is a fairly new plugin that has not yet gained much popularity. Nevertheless, it showed excellent results during testing. In addition, the plugin is quite simple to install and configure.

Results:

Requests per second - 130.75;
Time for each request - 76.48 ms;
Data transfer rate - 6325.36 Kbps

On average, this is 837% better than a blog without plugins.

Results of caching plugins for WordPress

I did not list all the plugins in this article because optimal choice is one of those discussed above. If you have the time, desire and knowledge of English, you can easily study the full results of the study comparing WordPress caching plugins.

Hyper Cache showed the best result, in addition, it provides good control over the process. It is quite possible to use WP-Cache or WP Super Cache. Both significantly improve productivity. In addition, they are from the “good old” cohort, proven by generations, which means they are well supported. I hope this article helped you decide which caching plugin to use. It's all about installation! As for me, for one of my blogging blogs I use the WP Super Cache caching plugin, it seems to help :)

Which WordPress caching plugin do you use and why?

Good day! It's no secret that WordPress is a multifunctional and convenient platform, but it is quite cumbersome. As traffic increases, the load on the server increases noticeably, performance decreases and, as a result, pages load slowly.

While working on optimizing my blog, I am extremely unhappy with this situation and once again I am trying to speed up page loading, improve behavioral factors, save your own and others’ nerves.

As a result of searching on Google, I came to the right decision - use page caching.

Website page caching algorithm

Since WordPress is a dynamic system, pages are generated every time they are accessed. At this stage, the requested page is generated on the server, which is assembled like a puzzle from various files template, as well as connected third-party files and scripts. After the page structure is formed, it is filled with content that is extracted from .

All these processes happen on the server side. Accordingly, if there is a sharp increase in traffic, the server cannot cope due to its limited capabilities and causes errors. Pages do not open or load very slowly. If the server resource limit is exceeded, the account may be disabled.

Helps cope with stress and reduce appetite WordPress caching— when accessing a dynamic page, it is generated on the server as usual, but the final version is saved statically in HTML format, i.e. This is a finished page.

During subsequent calls to the same page, the page from the cache is returned, and system resources at the same time they save money.

Hyper Cache - installation and configuration instructions

If you look at it from the very beginning, you can find many options for using various plugins for caching on WordPress, most of them have a similar principle of operation. Before working on this post, I tried installing several of the most famous ones, but the free Hyper Cache plugin brought the most tangible results.

Enabling Cache on WordPress

Before you start working with the plugin, you need to enable support for using cached pages on WP. This is done in the main configuration file wp-config.php, which is located in the WordPress installation folder. Open the file in text editor, I recommend using Notepad++ to avoid encoding problems, or use the built-in editor from your hosting control panel.

So, this line needs to be added to the configuration file:

Define("WP_CACHE" , true );

The developer page states that it should be inserted after the line:

Define ("WPLANG" , "ru_RU" );

Installing the Hyper Cache caching plugin

To install the plugin, you need to download it from the official trusted one, upload it via FTP to the plugins folder and unpack it. This is a very tedious method, in my opinion, I always install plugins directly from the admin panel: Plugins - Add a new one and then insert Hyper Cache into the search bar, the first one in the list is the required one:

I already have it installed, but I need to click on the Install link and then activate it. It is worth noting that work on this WP caching plugin does not stand still, as is often the case. Scheduled updates are carried out, functionality and security settings are improved, and compatibility with updates is ensured. Thus, the latest version to date is compatible with latest version CMS.

After installation and activation, a new item will appear in the administration console (Settings menu): Hyper Cache - it has numerous settings.

Setting up Hyper Cache, cache options on WordPress

For the plugin to work fully and to use the cache on WordPress, you need to perform detailed configuration of the plugin. At the very top of the page there is a button to clear the cache - Clear cache - you will need it if you have made changes in the structure or design and want users to see updated versions pages.

Cache status

This item indicates the number of pages in the WP cache and the next time the cached pages will be reset.

Settings

  • Cached page timeout - the time during which a page in the cache is considered relevant. For pages that have expired, the blog cache will be cleared automatically and recreated when accessed again.
  • Cache invalidation mode - indicates in which case a page should be deleted from the cache, I set it when an entry is changed.
  • Disable cache for commenters - the user leaves and then sees the current version of the page, and not the saved one. Those. there will be no confusion and he will see that the comment has actually been sent - either for moderation, or automatically posted.
  • RSS caching - I did not enable this feature because... When publishing a new article in RSS, it may appear with a delay, depending on the timeout set, and this is not good, especially if the information is new and very relevant.

Mobile Configuration

If there is a mobile version of the blog optimized for mobile devices, then the plugin will detect the device from which the login was made and save the cached page under a different name, which will allow you to show a saved copy of the same page optimized for different devices. To activate you will need installed plugin WordPress Mobile Pack.

I haven’t bothered with the mobile version yet, so I didn’t check the boxes next to the existing items.

Compression

Text optimization and transmission in compressed form. To save free disk space on the server, you can check the corresponding box. Again, by enabling these functions, compression occurs on the server side and therefore loses a small part of the performance and effect of caching.

I did not use these functions, you can try, just note that interruptions may occur, for example, blank pages will open.

Expert settings

  • Translation - if you want to see the Hyper Cache configuration page without translation, that is, in English, check the box.
  • Disable Last-Modified header - disable the time of its last modification in the page header.
  • Home page caching - check the box if you DO NOT want the home page to be saved in the cache.
  • Caching redirects - if available, then you can leave the option enabled.
  • Page not found caching (HTTP 404) - whether to save pages with a 404 error.
  • Strip query string - clearing the URL from additional queries in the address bar. It's something similar to .
  • URL with parameters - check if you do not use CNC and the page addresses contain a question mark.

Filters

  • Excluded URIs are addresses of pages that should not be cached.
  • Excluded agents are user agents (search bots, for example) for which the cache is not executed and is always shown current versions pages.
  • Cookies Match - If the cookies match, the cache will stop executing.

Attention! For the changes to take effect, do not forget to click on the Update button under each block of the listed settings.

This is so wonderful and most importantly - free WordPress caching plugin. It is noteworthy that a registered and logged-in user does not see the cached version of the page, but the current one, which is very convenient when making changes. Are you already using cache on WP?

Data caching in WordPress allows you to speed up your site and significantly reduce the load on your server. There are three main types of caching in the kernel—page caching, object caching, and transit caching. In this article, we will briefly talk about all three types, and also look at some popular caching plugins in WordPress.

What is cache?

A cache is an intermediate buffer that allows you to store the most frequently used data in memory or on the hard drive, which can significantly speed up the process of issuing them. Good examples where caching is beneficial are:

Each of these queries can be accelerated using caching. For example, if we display our latest Twitter message on the site's home page, we don't necessarily need to query Twitter every time we visit home page.

It is enough to make one request on the first visit and save the result for a certain time in the cache, and when you next visit the main page, we can return the saved result from memory much faster.

Caching in WordPress

There are three main types of caching in WordPress:

  • Page caching - allows you to save entire pages in the cache, and retrieve them from the cache on subsequent requests
  • Object caching - allows you to cache arbitrary data types
  • Transit caching - very similar to object caching, allows you to save data for a certain period of time

All three types of caching overlap or depend on each other under certain circumstances. We will tell you about each type in more detail, starting with the simplest and most common.

Page Caching in WordPress

It takes a lot of work to produce a single WordPress archive page. These are several queries to the database in order to get the latest posts, widget settings, theme settings, active plugins, site name and description, background image, title and much, much more.

Page caching allows you to save the result of the entire page. With a subsequent request to the same address, the same page is returned, but from the cache, which means much faster and with less load on the server.

When the content of a record or page changes, the page cache is reset, and upon a subsequent request it is already cached new page with updated data.

Page caching is not implemented in the WordPress core itself, but there are all the necessary functions to implement this at the plugin level. The two most popular page caching plugins are WP Super Cache and W3 Total Cache, although there are others.

WP Super Cache Plugin

WP Super Cache is the most popular page caching plugin in WordPress. It allows you to create and serve static HTML files for your pages, and with a certain configuration, you can set up the delivery of these pages directly by your web server (Apache or nginx), bypassing the processing of PHP files altogether.

New versions of the WP Super Cache plugin have some additional functions, for example, setting up a CDN, supporting a mobile version of the site, etc., but the main essence of this plugin is page caching.

WP Super Cache is suitable for both beginners and more experienced WordPress users, but since it uses file system for caching, it will be extremely difficult to use for a site with two or more web servers.

The W3 Total Cache plugin is newer than WP Super Cache, but is not inferior to it in functionality. It is gaining popularity very quickly, and today has more than 2 million downloads from the WordPress.org directory.

W3 Total Cache allows you to store cached pages both on your hard drive and in memory. It does not preserve the cache structure like WP Super Cache does, so you can configure the output without using PHP impossible, but unlike WP Super Cache, using external storage makes it easy to work in a multi-server architecture.

W3 Total Cache has a huge number of settings and additional functionality, including CDN support, database query caching, script and style compression, and much more. We recommend W3 Total Cache for more experienced WordPress users.

At the time of writing this article, the Batcache plugin has only been downloaded about ten thousand times from the WordPress.org directory, but in this case this is not an indicator of its effectiveness. In terms of performance, it is not inferior to either WP Super Cache or W3 Total Cache.

The Batcache plugin has only one function - page caching, but it does it flawlessly. Batcache uses external object caching to store data, making it easy to use in a multi-server architecture. This plugin is used by the massive WordPress.com network, with over 40 million sites, over 2,000 servers, and over 10 billion page views every month.

Which page caching plugin you choose depends on the size of your site, your capabilities, and your experience with WordPress. If you are not currently using page caching plugins, we always recommend starting with WP Super Cache. If it's important to you to have more features and finer caching configuration, try W3 Total Cache. If you are well versed in programming and server administration, and are willing to sacrifice the graphical interface when setting up, try Batcache.

Caching Objects in WordPress

Object caching is implemented in the WordPress core itself. This mechanism allows you to store objects of arbitrary types in memory and is mainly useful to developers of WordPress themes and plugins.

For example, when requesting an option from the database MySQL data using the get_option function, WordPress will store the result of this function in memory, and the next time it is accessed, it will return the result from memory without making queries to the database.

Similar caching in the core is implemented for many objects, including: options, posts (pages, and custom types), post metadata, terms and taxonomies. That's why WordPress developers shouldn't be afraid to use functions like get_option and get_post because... such calls do not cause unnecessary queries to the database.

Object caching in WordPress is done using a number of internal functions, including: wp_cache_add, wp_cache_set, wp_cache_get.

Persistent object caching

It's important to know that by default, object caching in WordPress is not persistent. This means that cached values ​​are only valid for one page request, and subsequent requests generate a clean slate for the cache.

At first glance, this is not at all beneficial, but if you count how many times WordPress calls the get_option function to process one request (about 500 times), then the benefit of object caching becomes obvious.

However, persistent object caching (or external caching) in WordPress is easily implemented using third-party plugins such as Memcached Object Cache or APC Object Cache. Both plugins allow you to use RAM server for storing WordPress objects, and the objects do not disappear when the request ends. This approach significantly reduces the load on the MySQL database.

It is also worth noting that when page caching is enabled, most often there is no time to work with saved objects, since the entire page is retrieved from the cache. This is not a reason to disable object caching, especially when working with logged-in users, and some plugins (for example Batcache) generally use object caching to store pages.

Transit Caching in WordPress

For users, this caching method is completely transparent. Transit caching allows developers to store data for a specific period of time. This method is implemented in WordPress using the get_transient, set_transient and delete_transient functions.

Transit caching is most often used to store fragments, especially when it comes to requests for external resources, for example, to display a message from the Twitter network or to display a weather forecast from a third-party service.

Similar caching is also used in the kernel when working with RSS feeds, and requests for updates to WordPress themes, plugins, and core.

Unlike object caching, transit caching is persistent by default in WordPress, and stores all data in the database. But it is important to note that when using a plugin for external object caching (for example Memcached or APC), transit caching will use this plugin to store data.

Object caching or transit caching?

It is quite easy for developers to choose between the two methods. If we need to save the result for a certain period of time and for more than one request, it is best to use transit caching. If we need to store a small object in memory only for the current request, object caching is suitable for us. If you need to save something for an indefinite period of time, the easiest way is to use the options - then there is a guarantee that the value will end up in the database.

When using a plugin to persistently cache objects, all three methods will use the plugin.

Conclusion

Caching plays an important role in increasing the performance and speed of sites, as well as optimizing them for high loads. In most cases, for sites with low traffic this is not so important, although it is always nice when the site opens faster.

For most sites, simple page caching solves all speed and load issues. This is the first thing to do if problems arise, especially on cheap hosting platforms. Page caching plugins are easy to install and configure.

Object caching and transit caching are fairly transparent to WordPress users, but it is important for developers to be well aware of and separate the two mechanisms. Plugins for external object caching often require more configuration effort than page caching.

Finally, remember that caching is just one way to improve your site's speed. If speed is important to you, don't forget about image optimization, script and style compression, query and database optimization, using CDN servers, and load balancing.

If you have any questions about caching in WordPress or problems setting up any caching plugin, please leave a comment and we will be happy to help you.

02.07.2013 05.11.2013

Co-founder of WP Magazine and the first WordCamp conference in Russia. Developer at Automattic, takes an active part in the development of the WordPress core. Favorite programming language: Python.