A fast Drupal website leads to a better user experience, higher conversions, and better rankings in Google. In this guide, we cover all the ways to optimize your Drupal site for maximum speed.

Why Performance is Important

Speed has a direct impact on your website:

  • User Experience: Visitors leave slow sites
  • SEO Rankings: Google rewards fast websites
  • Conversions: Every second of delay costs revenue
  • Server Costs: Efficient sites use fewer resources

Studies show that 40% of visitors leave a page that takes longer than 3 seconds to load.

Configuring Drupal Caching

Caching is the most important optimization you can do.

Enabling Internal Page Cache

Drupal has powerful built-in caching:

  1. Go to Configuration and then Development
  2. Click on Performance
  3. Configure Browser and proxy cache:
    • Page cache maximum age: Minimum 1 hour, preferably 1 day
  4. Click on Save configuration

Setting Cache per Content Type

For dynamic content, you can fine-tune caching:

  1. Go to Structure and then Content types
  2. Edit the content type
  3. Under Publishing options, adjust cache settings
  4. Save the changes

Clearing Cache

After changes, you may need to clear the cache:

  1. Go to Configuration and then Performance
  2. Click on Clear all caches

Via Drush (SSH):

drush cache:rebuild
# Or simply:
drush cr

CSS and JavaScript Aggregation

Aggregation combines files for faster load times.

Enabling Aggregation

  1. Go to Configuration and then Development
  2. Click on Performance
  3. Under Bandwidth optimization:
    • Check Aggregate CSS files
    • Check Aggregate JavaScript files
  4. Click on Save configuration

Benefits of Aggregation

  • Fewer HTTP requests
  • Smaller file size due to compression
  • Faster initial load time

After Adjustments

If you modify CSS or JS, clear the cache to refresh the aggregated files.

Database Optimization

An optimized database is essential for performance.

Run Cron Regularly

Drupal cron cleans up the database:

  1. Go to Configuration and then System
  2. Click on Cron
  3. Set the frequency (at least every 3 hours)
  4. Or run manually: click Run cron

Via crontab (recommended):

# Run cron every 6 hours
0 */6* * * cd /path/to/drupal && drush cron

Optimizing Database Tables

Via phpMyAdmin:

  1. Open phpMyAdmin in DirectAdmin
  2. Select your Drupal database
  3. Select all tables
  4. Choose Optimize table in the dropdown menu

Cleaning Cache Tables

Drupal stores a lot of cache in the database:

# Via Drush
drush sql-query "TRUNCATE cache_default"
drush sql-query "TRUNCATE cache_render"
drush sql-query "TRUNCATE cache_page"

PHP Optimization

Optimize PHP for better Drupal performance.

Activating OPcache

OPcache significantly speeds up PHP:

  1. Check if OPcache is active via Reports and then Status report
  2. Or via phpinfo()
  3. At Theory7 hosting, OPcache is enabled by default

Increasing PHP Memory

For complex sites:

  1. Go to DirectAdmin
  2. Click on Domain Setup and then PHP Settings
  3. Increase memory_limit to 256M or 512M
  4. Save the changes

PHP Version

Always use the latest PHP version:

  • PHP 8.2 or 8.3 recommended for Drupal 10
  • Newer versions are significantly faster

Module Optimization

Modules can greatly affect performance.

Disabling Unnecessary Modules

Every active module consumes resources:

  1. Go to Extend
  2. Review all active modules
  3. Disable unused modules
  4. Remove them completely if possible

Installing Performance Modules

Consider performance modules:

  • BigPipe (core):
    • Loads pages progressively
    • Included by default in Drupal 10
  • Advanced CSS/JS Aggregation:
    composer require drupal/advagg
    
    • Advanced optimization of assets
    • Bundling and minification

Identifying Slow Queries

Via database logs or modules:

  1. Activate slow query log in MySQL
  2. Analyze the slow queries
  3. Add indexes where necessary

Views and Content Optimization

Views can be slow if not configured properly.

Enabling Views Caching

  1. Edit the View
  2. Go to Advanced settings
  3. Click on Caching
  4. Set time-based caching
  5. Save the View

Using Pagination

Limit the number of items per page:

  1. In the View, go to Pager
  2. Set a reasonable number of items (10-25)
  3. This prevents heavy database queries

Limiting Content Preloading

Load only the fields you need:

  1. Use Fields instead of Content display
  2. Select only the necessary fields
  3. Avoid complex relationships

Optimizing Images

Images are often the largest files.

Using Image Styles

  1. Go to Configuration and then Media
  2. Click on Image styles
  3. Create styles for different formats
  4. Drupal automatically scales images

Activating Lazy Loading

Load images only when they come into view:

  1. Drupal 10 has basic lazy loading built-in
  2. Consider modules like Lazy-load for more control

WebP Format

Use WebP for smaller files:

  1. Check if your server supports WebP
  2. Use Image Styles to generate WebP
  3. Modern browsers display WebP, older ones get a fallback

Performance Monitoring

Regularly measure your results.

Internal Tools

  1. Go to Reports and then Status report
  2. Check performance metrics
  3. View database and cache status

External Tools

  • Google PageSpeed Insights: Comprehensive analysis
  • GTmetrix: Load times and waterfalls
  • WebPageTest: Detailed metrics

Performance Checklist

  • Page cache active
  • CSS/JS aggregation on
  • Cron runs regularly
  • OPcache active
  • Images optimized
  • Unnecessary modules disabled

Need Help?

We are here for you! Are you facing any issues or do you have questions? Our support team is happy to assist you personally. Send us a message via the ticket system - we usually respond within a few hours and are happy to help.