> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Optimizing Drupal for performance

> There are a number of ways to optimize your Drupal site to make it perform faster. Follow our guide to easily configure your site for the best performance.

This article describes specific steps you can take to optimize a Drupal site.

## Optimizing Drupal

Drupal includes several configuration options that you can use to help improve your site's speed and responsiveness. The procedures below show how to configure these options so they are optimized for high performance.

<Note>
  The settings described in this article are for Drupal 7. Earlier Drupal versions may not include some of these settings.

  👍 Tip

  If you configure the settings as described below and your site's performance is still not at the level you want, there are additional options:

  * Turbo Hosting use a drop-in Apache replacement that can load pages significantly faster than regular web hosting accounts.

  * Managed VPS, Managed Dedicated Server, Turbo Hosting can use [Memcached](/docs/do-you-support-memcached-hosting)to decrease page load times.

  * Managed VPS and Managed Dedicated Server accounts can use [Redis](/docs/do-you-support-redis)to decrease page load times.
</Note>

### Caching

Drupal includes a built-in caching feature, but it is disabled by default. To enable caching for your site, follow these steps:

1. Log in to Drupal as the administrator.

2. On the top menu bar, click **Configuration**.

3. Under **DEVELOPMENT**, click **Performance**.

4. Under **CACHING**, select the **Cache pages for anonymous users** check box.

5. Select the **Cache blocks** check box.

6. In the **Minimum cache lifetime** list box, select the length of time that Drupal should store files in the cache until they are refreshed.
   > 👍 Tip
   >
   > If your site content does not change frequently, you can set the cache lifetime to a longer interval. Similarly, if you update site content frequently, you should set a shorter cache lifetime interval.

7. In the **Expiration of cached pages** list box, select the length of time external caches can use old versions of pages.
   > 👍 Tip
   >
   > In this case, *external caches* refer to client applications, such as web browsers.

8. Click **Save configuration**.
   > 🚧 Important
   >
   > Drupal's caching features can cause the database to grow very large, which can affect server performance. For information about how to periodically clear Drupal's caches, please see [this article](/docs/optimizing-drupal-database-usage).

### Cron job

Drupal includes a cron job routine, but it does not run by default. You should run the cron job, however, because it performs many routine maintenance tasks that help ensure better performance. For step-by-step instructions about how to configure Drupal's cron job for your site, please see [this article](/docs/configuring-the-drupal-cron-routine).

### Compression

You can add Apache **mod\_deflate** directives to the *.htaccess* file in Drupal's root directory to compress output. Compression saves bandwidth and ensures faster page download times.

<Warning>
  **Important**

  When caching is enabled, Drupal includes its own compression option in the administration interface. To access this option, on the top menu bar, click **Configuration** . Under **DEVELOPMENT** , click  **Performance** . Under **BANDWIDTH OPTIMIZATION** , look at the **Compress cached pages** check box. If this option is enabled, do **not** follow the Apache compression configuration steps below (unless you clear the check box and disable the option). You should only use one of these compression methods at a time, not both simultaneously.
</Warning>

To enable output compression for Drupal, follow these steps:

1. Using your preferred text editor, open the *.htaccess* file in the directory where you installed Drupal.

2. Add the following lines to the *.htaccess* file:

```
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript
</IfModule>
```

3. Save your changes to the *.htaccess* file. The changes take effect immediately.

### JavaScript and CSS files

You can help reduce your site's page load times by optimizing JavaScript and CSS files. This process includes:

* Combining JavaScript and CSS files. This reduces the number of HTTP requests necessary to load a page.

* Minifying (removing all unnecessary characters from) JavaScript and CSS files. This reduces the amount of bandwidth required to load a page.

To do this, follow these steps:

1. Log in to Drupal as the administrator.

2. On the top menu bar, click **Configuration**.

3. Under **BANDWIDTH OPTIMIZATION**, select the **Aggregate and compress CSS files** check box.

4. Select the **Aggregate JavaScript files** check box.

5. Click **Save configuration**.

### Database tables

You should periodically optimize the Drupal database to help ensure your site loads as quickly as possible. The [DB Maintenance](https://www.drupal.org/project/db_maintenance) module enables you to quickly and easily optimize Drupal database tables at fixed intervals. You can configure the module to optimize all of Drupal's database tables, or just specific tables.

<Note>
  The DB Maintenance module supports both the MyISAM and InnoDB engines. For more information about MySQL database engines, please see [this article](/docs/working-with-mysql-database-engines).
</Note>

To install and configure the DB Maintenance module, follow these steps:

1. Use your web browser to go to [https://www.drupal.org/project/db\_maintenance](https://www.drupal.org/project/db_maintenance).

2. Under **Downloads**, download the.gz file for your Drupal version to your computer.

3. Log in to Drupal as the administrator.

4. On the top menu bar, click **Modules**, and then click **Install new module**.

5. Click **Browse**, select the.gz file on your local computer, and then click **Install**. Drupal installs the DB Maintenance module.

6. Under **Next steps**, click **Enable newly added modules**. The **Modules** page appears.

7. Scroll down to **OTHER**, and select the **ENABLED** check box next to the DB Maintenance module.

8. Click **Save configuration**.

9. On the top menu bar, click **Configuration**, and then under **SYSTEM**, click **DB maintenance**. The DB Maintenance module configuration page appears.

10. In the **Optimize tables** list box, select how often you want the database tables optimized.
    > 📘 Note
    >
    > If you have a busy site, you may want to optimize database tables more frequently.

11. Select the tables you want to optimize:

    * To optimize all of the tables, select the **Optimize all tables** check box.

    * To optimize specific tables, select the table or tables in the list box.

12. Click **Save configuration**.

### Database logging

Drupal includes a database logging feature to help debug and troubleshoot problems. Although helpful for diagnosing problems, it can also cause the database to grow very large. This consumes system resources and negatively affects server performance.

For information about how to optimize database logging, please see [this article](/docs/optimizing-drupal-database-usage).

## Related articles

* [Configuring caching with the mod\_expires module](/docs/configuring-caching-with-the-mod-expires-module)

* [Data compression using the mod\_deflate module](/docs/data-compression-using-the-mod-deflate-module)
