Drupal's cache technology application-let your website Fly

Source: Internet
Author: User
Tags anonymous apc redis drupal drupal cache varnish website performance zend

Therefore, you cannot completely solve the performance problem, but you can use some common solutions to significantly improve the website performance based on the actual situation. We often say that you know the 80/20 theory, so if you exchange 20% effort for 80% performance improvement, why not.

As a Web open-source system, Drupal is called CMF (content management framework) and has excellent architecture and scalability, as well as a large number of third-party modules, more and more people are familiar with and adopt it. One advantage of using mainstream Web systems such as Drupal is that many excellent experts from around the world have invested in it, providing a variety of performance optimization solutions. Most of us, as users, can significantly improve the performance of our websites as long as they know how to choose an optimization solution that suits them.

All of the above are Performance Optimization. In fact, the focus of this article is the cache technology. In my opinion, for Drupal, the cache and performance optimization are basically synonymous, most Drupal optimization technologies use a variety of caches. Cache includes static page cache, dynamic cache, CSS, Javascript, and image cache. Some are stored in the memory, some are stored in the database, some are stored on the disk, and some need to be provided with some server software. Mr. Lin, it is very likely that new users will be excited. Therefore, this article is intended to provide guidance to new users on the cache topic. I have limited knowledge and cannot cover all aspects. I hope readers can criticize and correct me.

Core cache

As the most basic optimization method, Drupal provides some basic support for caching, such as external block caching, anonymous user page caching, and menu system caching, topic hook registry cache and so on.

It can be said that, as a small Drupal site, using the conventional built-in core means, the performance will not be too bad. In general, caching is not enabled in the development phase. However, once a block cache is launched, static pages of block caching and anonymous users must be enabled, CSS and JS must also enable merge compression. In this way, the speed of anonymous users is much faster than before.

Boost


The default anonymous user cache provided by Drupal is stored in the database, which means that even cached webpages occupy the database connection and Intranet traffic. If you replace it with the Boost module, your cache goes directly to static files. This is not just because you don't go through the database or even Drupal. Therefore, as for the page cache, Boost works extremely well.

Varnish HTTP Accelerator Integration

The Varnish module is listed here to tell you that if your server still has a large memory, if you use the Varnish server software before, you can cache static web pages to the memory opened by Varnish, which is faster as you can imagine. Varnish can also help you cache static files such as CSS and Javascript.

Memcache API and Integration, Memcache Storage, Redis

The access of anonymous users is already so fast. What should I do if there are many active login users on your website? Most of the previously mentioned cache will be invalid, for login users, the most effective way is to use Memcache so that the internal cache of many systems can be read from the memory for better performance, and Memcache itself can still be deployed in a distributed manner, good scalability. The last Redis is equally good. Here we do not compare the advantages and disadvantages between them, but we recommend that you start with Memcache.

Memcache API and Integration and Memcache Storage, you only need one, and the latter is recommended.

APC-Alternative PHP Cache

Another technology that can make login users feel faster is Alternative PHP Cache, which is APC. Its role is to make PHP files cached to the memory instead of being loaded from the disk every time, it is cache-Based Compilation of intermediate code, so the optimization effect is obvious for complicated PHP systems. This can be said to be a required component for all PHP websites. Of course, it also has other competitors, such as eAccelerator, XCache, and the latest Zend Opcache. However, before the Zend Opcache component appeared, APC performed slightly better in Linux systems than others, while the new Zend Opcache was said to be somewhat stronger than APC (less than 10%), but likewise, we recommend that you start with APC. Here is an article (link is external) that can serve as an extended reader.

In addition, if we closely use the Opcode caching feature of APC code files, we do not need this module. This module provides additional data to be cached to APC, in this way, we can put some of the infrequently changed cache tables into APC, and the frequently changed cache tables into Memcache, while other large cache tables need to be placed in the database.

Entity cache

What to do next, because this article is based on Drupal 7. After Drupal 7 introduces the concept of Entity, Drupal has various types of Entity, so this module provides cache support, this will make your login users feel a little faster and requires no configuration, and will take effect for almost all Drupal sites.

In addition, there are still many modules related to Drupal kernel mechanisms and common third-party modules on the official website. For example, the Views Row Cache module and the Views content cache provide different logic caching mechanisms for Views. We can choose this type of module based on the actual situation. After all, it is slow to install more modules.

Authenticated User Page Caching (Authcache)

 

Then, let's talk about the more ideal login user Cache Problem. If the page is dynamically generated, how can we cache it? The performance is not as good as that of static pages directly, is there a way? The Authcache module can help you to a certain extent, but it should be noted that the login user cache is very complicated. We have to think about it well before using the Authcache module.

For example, if you create an SNS website, you feel that the user login page is not fast enough. If you enable the Authcache module. You need to think that those pages are exactly the same for users, so that they can be cached. Most of the pages are the same, and only a small part of them are different from each other, the processing of Authcache is complicated. If you want to cache pages like new things, they will be different for every user, that means that the order of magnitude of the page to be cached is the number of user IDs multiplied by the number of URLs and then the number of roles. Is it feasible to think about how much space the cache will occupy ?.

I have mentioned so much about the Authcache module. I would like to remind you that choosing Authcache should be very careful. It may not be good, but may not be suitable for you.

CDN

The page opening speed is related to many factors. One of the most important factors is the download speed of CSS and Javascript files. The physical distance between the user and the server will have a great impact on this. Therefore, we need the help of CDN (Content Delivery Network) technology, allows users to access the cached version of the website resource files. CDN not only makes your website open faster, but also shares the traffic and connections for your website, so your website can support more concurrent accesses.

The CDN module can help you configure and make your CDN take effect. Note that it is normal to use CDN for CSS and images, but Javascript should be noted that if all Javascript code uses CDN, security risks and user experience may occur.

Cache Warmer


Finally, let's talk about the cache reconstruction problem. Since it is a cache, it is not available at the very beginning. It is generated a little bit with the user's access, so when the user accesses it for the first time, the website is still very slow. If you have a large number of website pages, many users will feel that your website is slow, and even the second page is lost if you no longer visit it, therefore, after the cache is cleared every time (in fact, Drupal clears the cache frequently, especially for Drupal sites that have been developed and operated for a long time), we need to re-cache the important entry pages, to increase the visitor's stay time and reduce the bounce rate.

Cache Warmer is such a technology. It is more purposeful than crawler ideas, such as important portal pages, new website content, and popular website content. However, when using this technology, pay attention to what you can do. Don't paralyze your website when recreating the cache.

Summary

There are quite a few Drupal cache-related modules, which can be investigated and used based on the actual situation of the project. This article introduces various common caching technologies for Drupal websites in a simple and in-depth order, so that you can have a general and complete understanding of Drupal's caching technology, so as to have a better understanding of performance optimization.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.