How To Speed up a Slow Drupal Site ?

  0 comments
Share

The reason behind Drupal sites run slowly is that Drupal will load many CSS and JavaScript files by default. And, each time you install a module to Drupal, there is a chance you are adding even more files.

Before you move on to our recommended solutions, go to your site and check the source code. If your source code seems like the image below, keep reading and we'll show you how to fix this problem.

Source js

Dealing with many CSS and js files

Go to /admin/config/development/performance.

There are two performance configuration options on this page: Caching and Bandwidth Optimization.
Enable "Cache blocks" next to Caching.
Enable "Aggregate and compress CSS files" and "Aggregate JavaScript files" under Bandwidth Optimization.

Performance

CSS compression results

Aggregate css Image

JS compression results

Aggregate Js Image

Compressed with gzip

Just open your .htaccess file from drupal core and add these few lines at top to gain in speed and preserve your bandwidth

<ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x- javascript application/javascript </ifmodule> <IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|xml|txt|css|js)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule> <IfModule mod_expires.c> ExpiresActive on ExpiresByType text/html "access 2 day" ExpiresByType text/css "access 2 day" ExpiresByType application/javascript "access 1 month" ExpiresByType text/plain "access 1 month" ExpiresByType image/jpeg "access 1 month" ExpiresByType image/jpg "access 1 month" ExpiresByType image/gif "access 1 month" ExpiresByType image/png "access 1 month" ExpiresByType application/pdf "access 1 month" ExpiresByType application/x-shockwave-flash "access 1 month" ExpiresDefault "access 2 days" </IfModule> <ifModule mod_headers.c> Header set Connection keep-alive </ifModule>

Add new comment