×

While the Drupal content management system (CMS) is great at getting your site up and online in an easy-to-use manner, the default installation comes with quite a bit of bloat. Because users tend to be impatient, you should take care to optimize your site to minimize the page load times seen by your users. This article covers several techniques you can implement to improve the performance of your Drupal site. We will first cover the fixes you can make by changing your site’s configuration settings. Then, we will cover improvements resulting from use of Drupal’s modules.

Using the Latest Version of Drupal

If at all possible, you should run the latest version of Drupal, as well as contributed modules and themes. New releases contain bug fixes and performance improvements, and you can take advantage of these things by keeping your core, contributed modules, and themes up to date. You can check to see what, if anything, needs to be updated by navigating to Reports → Available Updates while you’re in the Manage Dashboard.

How to Optimize Your Drupal Site

Configuring Your Site for Optimal Performance

Drupal has several built-in settings that can help improve your site’s performance. To see these settings, navigate to Manage → Configuration → Performance. On this page, you can enable or disable specific functions included in the Drupal Core installation. These are some of the most basic things you can do to improve your site’s performance.

How to Optimize Your Drupal Site

Caching

Every time a user loads your page, the web browser sends a request and your servers, including your database, respond by providing the required files to render your page. This results in the execution of a bunch of database queries, each of which takes time. However, for static pages that do not change between users, Drupal’s Internal Page Cache can cache the rendered contents (which is HTML content) and store it in a separate database cache so that it can be recalled quickly for different users. For example, if you have multiple users visiting your site from different computers, Drupal first looks at the database cache table to see if the page is there, and if it is, Drupal will serve the page from the cache instead of calling the database. Essentially, setting this feature reduces multiple database queries into a single query that will serve multiple users.

To use this feature, set the value for page cache maximum age. You can choose to cache for a minimum of 1 minute to a maximum of 1 day. Try to cache for as long as possible to gain the most benefit performance-wise for your site.

Drupal’s built-in caching feature only works for users that are anonymous to your site (and therefore not logged in or otherwise identifiable). For identifiable users, you can choose to enable special page areas that are known as blocks. Blocks show up as customized content (such as user profiles, dynamic location data, or pages that have user-specific settings), and this data is not appropriate for display to all users. If your site utilizes these features, you will need to use the Dynamic Page Cache feature, which caches all static content and works for all users, regardless of whether they’re anonymous or not.

Bandwidth Optimization

Under this section, you can enable one or both of the following options:

  • Aggregate CSS files
  • Aggregate JavaScript files

Due to Drupal’s flexibility, you will see some tradeoffs in terms of performance. One of the areas where Drupal’s flexibility and ability to be customized leads to performance tradeoffs is with regards to CSS and JavaScript files. For example, even the most basic of Drupal sites can contain over 30 CSS files and a multitude of JavaScript files. This is because Drupal operates using modules, and anytime a module requires JavaScript or CSS, an additional file is included. This is in addition to anything required by your site’s theme. Each of these files is a separate HTTP request, and you can easily see how the number of such calls can quickly increase to the point where the lag is extremely noticeable to your users. As such, you will want to reduce the number of requests to the web server to ensure your page loads as quickly as possible.

By enabling the Aggregate CSS Files and/or the Aggregate JavaScript Files feature(s), Drupal will reduce the number of CSS files required by your site. Drupal does this by concatenating all of your files together and then splitting them up into a few files. This ensures the balance between making too many calls for too many files and making too few calls for files that are larger than they should be.

Disable Unused Modules

By going to Manage → Extend, you can view a full list of modules that you have installed. You should go through this list regularly and disable any that you are no longer using, since having unused modules results in additional calls for and time to parse PHP, CSS, and JavaScript files with each page load.

Configure Cron Job

By default, Drupal’s “automated cron” system is set to run every three hours to check for updates, indexing content, and clearing temporary files.

How to Optimize Your Drupal Site

While the Cron job is great for cleaning up your site, so to speak, running it requires resources (in terms of server processing power and memory), so visitors to your site while Cron is running will see slower page load times. As such, you may want to increase the amount of time between Cron jobs.

Installing and Using Performance-Related Modules

You can use modules to extend and customize the functionality of your site, as well as integrate with third-party services. The default Drupal installation comes with several useful modules, but there are many others you can install if the included ones do not meet your needs. These additional modules are called contributed modules, and you can read more about installing modules at SiteGround.

Integrate Your Drupal Site with a Content Delivery Network (CDN)

By integrating your Drupal site with a CDN, you can deliver content to your users using the server(s) closest to them. Minimizing the distance between the users and the server hosting the data will reduce the amount of time the users spend waiting for a site to load, as well as take advantage built-in features such as resource optimization. As such, you should consider using a CDN to serve as many of your resources as possible. While caching reduces the number of HTTP calls required, using a CDN minimizes the overhead required in the event that an HTTP call is made. In addition, your CDN might offer up content in its most optimal form and offer built-in scalability features, which is helpful for unexpected surges in traffic.

Optimize Your Images

Images, while an extremely important part of your site, are expensive assets, and you should take care to optimize these to the best of your ability. The following modules can help minimize the overhead generated by using images on your site.

Use Image Sprites: You can create image sprites to send multiple background images within the same HTTP request. Two modules that you can use to generate sprites are CSS Sprite Generator and Spritesheets.

Lazy-Load Images: By lazy loading images, your site only delivers the images that are above-the-fold. Only when the user scrolls down are additional images requested and rendered, which results in a faster page load and fewer resources used. Some modules that can add this feature to your Drupal site are Image Lazyloader or Lazyload. For lazy loading images on Drupal’s views, you can use Views Lazy Load.

Use Image Optimization: Drupal’s core Image Toolkit module can change the quality of your images, but you can garner additional image size savings.

How to Optimize Your Drupal Site

By utilizing the ImageAPI Optimize module to losslessly optimize your images whenever you save your images and the Image Resize Filter to ensure that the images you upload aren’t too big, you can speed up the loading of your page.

Optimize Your Database

One easy way to optimize your Drupal database is to use the OptimizeDB module. Once you have installed and activated the module, you can select some or all of your database tables to optimize. This process includes clearing out selected tables (such as caches), rebuilding or repairing tables, sorts indexes, and updates table statistics. Using this module allows you to perform basic optimization and cleanup of your database tables without requiring you to learn query languages and be familiar with your database’s structure.

Conclusion

Drupal’s out-of-the-box configuration comes with quite a bit of bloat, which leads to slower page load times for your users. You can easily improve your site’s performance by changing just a few of your site’s configuration settings and installing Drupal modules that extend your site’s abilities, and these techniques are easy to implement for many users.

If, however, you think there are additional improvements to be made to your site, please contact Rigor for a free performance report that contains additional personalized information on what you can do to ensure that your site is running as fast possible.

Suggested Blog Posts