# Optimizing Drupal for performance

> Speed up your Drupal site by turning on caching, compression and CSS and JavaScript aggregation, running cron and tidying the database.

Source: https://helpcenter.ruachost.com/apps/drupal/optimizing-drupal-for-performance/

Drupal is a powerful CMS, but without proper optimization, sites can become slow and resource‑intensive. On **ruachost.com**, you can configure Drupal to run faster by enabling caching, compression, and database optimization.

## Why Optimize Drupal?

- Faster page load times → Better user experience.
- Reduced server load → More efficient resource usage.
- Improved SEO → Search engines reward faster sites.
- Scalability → Handle more visitors without downtime.

## Steps to Optimize Drupal Performance

### 1. Enable Caching

1. Log in to Drupal as an administrator.
2. Go to **Configuration → Development → Performance**.
3. Under **Caching**, enable:

   - **Cache pages for anonymous users**.
   - **Cache blocks**.
4. Set **Minimum cache lifetime** and **Expiration of cached pages** based on how often your content changes.

### 2. Configure Cron Jobs

- Drupal includes a cron routine that performs maintenance tasks.
- Go to **Configuration → System → Cron**.
- Set a schedule to run regularly (e.g., every 6 hours).

### 3. Enable Compression

- Add Apache `mod_deflate` directives in `.htaccess` to compress output:

  ```
  
  AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript
  
  ```
- Or enable **Compress cached pages** under **Performance → Bandwidth Optimization**.

### 4. Optimize JavaScript and CSS

1. Go to **Configuration → Development → Performance**.
2. Enable:

   - **Aggregate and compress CSS files**.
   - **Aggregate JavaScript files**.
3. This reduces HTTP requests and bandwidth usage.

### 5. Optimize Database Tables

- Install the **DB Maintenance module** from Drupal.org.
- Configure it under **Configuration → System → DB Maintenance**.
- Set optimization frequency (daily/weekly) and select tables to optimize.

### 6. Manage Database Logging

- Excessive logging can slow down performance.
- Go to **Configuration → Development → Logging and errors**.
- Limit logging or use external monitoring tools.

## Important Notes

- Caching may increase database size, clear caches periodically.
- Only enable one compression method (Drupal or Apache), not both.
- Always back up your site before making performance changes.
