Speed Up Your Drupal Website with Caching

To sustain this free service, we receive affiliate commissions via some of our links. This doesn’t affect rankings. Our review process.

Turtles on grassWhat is caching? A cache is a repository that saves a static version of a page, and loads it up when a user requests it. Websites, as well as browsers, use caching to reduce page load times and increase performance. By loading a static version of a page, there is all kinds of resource usage that can be saved – from database calls to loading images. Basically, a cached page is a saved version of a page that is loaded up when a user requests it. Caching is especially useful for pages that don’t change often. If a page doesn’t change, there’s no point for a website or browser to reload and recreate every aspect of a page, making calls to databases, etc. to grab content, every single time a user visits the page. Without caching, a server’s performance is impacted, bandwidth usage increases, and web page load times slow to a crawl.

What Caching Options Does Drupal Have?

With Drupal, you have several caching options at your disposal, especially if you have Drupal 6.x or later installed. The default Drupal installation comes with cache settings that you can access at /admin/settings/performance. Our recommended settings are as follows:

  • Caching mode: Normal
  • Minimum cache lifetime: 1 hour
  • Page compression: enabled
  • Block cache: enabled
  • Optimize CSS files: enabled
  • Optimize JavaScript files: enabled

The main thing to note here is the minimum cache lifetime. By setting the cache to 1 hour, you are storing pages in the cache for one hour before refreshing them. This means if there’s an update to a page an anonymous user will see it within the hour.

There’s also a clear cached data button that you can use to clear out all the caches at once. This is especially useful if you made a change to the site and are not seeing it, and are not sure where it may have been cached.

That brings us to an important distinction:

Drupal’s default page caching only applies to anonymous users

This means if you’re logged in, page caching will not be performed. This means page caching primarily benefits sites with a large amount of anonymous (not logged in) users. If your site is primarily affected by traffic from logged in users, you’ll want to consider some of the caching modules below, in addition to Drupal’s default caching options.

Turn off Caching for Development

If you’re working on your site layout, or anything to do with CSS, graphics, etc., ie. you’re developing or designing your website, you’ll want to turn caching off so you can see the changes immediately.

Additional Caching Modules for Drupal

In addition to Drupal’s default cache settings, there are quite a few useful modules you should consider to increase your website’s performance:

  • Boost – The Boost module provides static page caching for Drupal, which should result in a significant performance and scalability boost for sites that receive mostly anonymous traffic. Apache is fully supported, with Nginx, Lighttpd and IIS 7 semi-supported. Boost will cache & gzip compress html, xml, ajax, css, & javascript, and you can have different cache lifetimes for different parts of your site. Boost uses a built-in crawler that regenerates expired content for fast page loading.
  • Cache RouterCacheRouter provides a caching system that you can use to assign individual cache tables to different caching technologies – meaning you can use multiple caching mechanisms at once. CacheRouter also caters to anonymous users by allowing you to utilize Drupal’s page_fast_cache part option.

Drupal Caching via Cron

Caching modules typically rely on cron calls (scheduled commands performed on your database on a regular basis). If you’re not familiar with cron jobs, you’ll probably want to download and install Drupal’s PoorMansCron module.

Disclaimer: This website contains reviews, opinions and information regarding products and services manufactured or provided by third parties. We are not responsible in any way for such products and services, and nothing contained here should be construed as a guarantee of the functionality, utility, safety or reliability of any product or services reviewed or discussed. Please follow the directions provided by the manufacturer or service provider when using any product or service reviewed or discussed on this website.

Alex bring a series of in-depth articles on search marketing and content management systems as well as troubleshooting tips to We Rock Your Web's collection. He is an avid tennis player, nature enthusiast, and hiker, and enjoys spending time with his wife, friends, and dogs, Bella and Lily.

6
Leave a Reply

avatar
newest oldest most voted
Anonymous
This caching option is not available to users who are logged in to the system. In other words, if you are in the process of working on your system, this is not something you should worry about. That is good news, since you would certainly be interested in seeing the immediate effect of all your changes, not waiting an hour or so to see the next updated version. This also means that these caching options are most beneficial for sites that have a large amount of outside or anonymous traffic.

On the other hand, if your site does have a lot of internal traffic, there are other caching options you may want to consider. By internal traffic, the author means users who are able to log in to the system. Actually, most of these are modules which have been created by other developers in response to their current needs. Boost is just such a module that actually enables caching and compressing a number of different file formats, including HTML, XML, AJAX, CSS and more.

Another excellent module that can be used for caching activities is called Cache Router. This will allow you to assign individual cache tables to different caching techniques or technologies. What this means to us layman is that you can specify which caching method you want to use for different pages, and even fro different elements within each page. Additionally, you may also use multiple technologies at the same time.

Anonymous
The real advantage of caching is that it reduces the load time of a page. Additionally, it saves resource usage. Granted, if a web page just has a few pieces of text, this is probably not a big issue. However, when we are talking about a large web site that has images, videos, databases and more, this can save quite a bit of time and resources. Also, if a page or site does not change that often, than caching makes even more sense.

One of the cool things about caching is that this technology is used by internet browsers all the time as well. Although most websites do not take up a huge amount of resources, there is simply no point to constantly loading and reloading when a page can be stored in memory and accessed quickly should the need arise. Especially considering the fact that the likelihood a page will change while you are browsing the site is rather remote.

The author then goes on to point out that with Drupal, you are given several different caching options. The recommended choices include using a minimum cache lifetime of 1 hour, enabling page compression, block cache, optimizing CSS files and JavaScript files. This will allow any cached pages to be stored for up to one hour. After an hour, the page would then be refreshed (reloaded) and the new version stored with the cache for up to another hour.

Another important point which the author neglected to mention is that is another reason why computers tend to slow down over time. These pages which have been stored in the cache tend to build up over time. This clogs system resources, takes up space and memory. All regular internet users should clear out their cache on a regular basis. This is easily done by clicking on your browser toolbar and then internet options. Of course, each browser will probably be a bit different.

Anonymous
Caching is a good idea. It will make your browsing faster. Thanks for this great idea.

Kristy Martin

Anonymous
Fast pages and useful content is an almost guaranteed way to increase site traffic. But is there a way to remove the word “node” from the url?

Anonymous
Enable the Path module to create your own URLs, or also use the Pathauto module to create automatic URLs.

Ollie.

My Drupal Blog

Anonymous
Boost makes an unbelievable difference in page loading speed, and it doesn’t seem to conflict with Drupal’s native caching nor my various JavaScript applets that I have embedded in my pages. My vote goes for boost.

If you have time on your hands, some of the other methods may prove beneficial as well, but for most applications I’m thinking Boost does the trick.