Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Authcache: caching for registered users CAN happen!

Parent Feed: 

Recently, I had to build a Drupal site that had to be fast for registered and non-registered users. One of the most frequently used module for caching, boost, can offer caching for unregistered users only. But what can we do for the rest of our visitors?
Why can't we offer them more speed? 

The solution

The module I used is authcache and can give us a plain and straighforward configuration that can be used with or without advanced caching server software. For example, if our web server has no Varnish or opcache or memcache etc. we can get from the module a very satisfying out-of-the-box result providing fast page surfing for our registered visitors. 

In a nutshell, the module is similar to the well known boost. The first time a page is requested, a HTML version of it is stored for future requests. Each user role, has its own HTML version of the requested page. Once the cached page is stored, whenever it's been served as static page, an additional AJAX light-weight request is made to the server in order to update the usage statistics of the page requested and as a result the module returns personalized data for this page such as FAPI tokens, FAPI default values etc.

And where are the cached files?

Authcache gives us the ability to expand its functionality with extra features that allows us to use any advanced caching software the server may have. By adding some contrib modules, we can store the cached content either on files, Redis, Memcache, MongoDB etc. By default the module stores the content on our database. That may be a solid approach, but we suggest to use the File Cache module so that the content is stored in sites/default/files folder. With that aproach, MySQL stores only the URL and the age of each stored page. That keeps our database more clean and easier to maintain. Like many caching modules, authcache, has configurable settings such as minimum/maximum lifetime, cache update triggers, debugging modes etc as well.

What do the numbers say?

If a registered user requests a page that has 2 views, 3 blocks, 2 menus and some more "plain" content, the average rendering time is ~650ms. That means that a registered user has to wait for ~650ms after his click before the server can send to him the 1st byte of our page. 
With authcache and File Cache, we got to ~48ms!

These numbers are recorded on a 64bit Windows 7 laptop with SSD and plenty of memory (8GB). You will never going to host you site on something like that, but you get the picture. And if you use any of the contrib modules with the appropriate server software, you WILL get even better response times.

If you use authcache, boost, Block Cache Alter and the native caching of Drupal and Views, you will turn your sluggish Drupal installation to a rocket!

And never forget: Keep your site fast, keep your visitors happy!

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web