I use YSlow to check a Drupal site performance. Here some tips to get an A with Drupal 5.x.
Step 1: Fewer HTTP requests:
- Aggregate CSS (/admin/settings/performance)
- Aggregate JS with Javascript Aggregator (experimental). To avoid JavaScript errors in some modules (i.e. TinyMCE), you can use the dirscard list patch by derjochenmeyer on the dev version (it’ll be added to the next release). To Drupal 6.x users: Drupal 6.x comes with a native JS Aggregator support, so you don’t need an additional module.
- Reduce CSS background images: select carefully your theme.
Step 2: Compress pages on-the-fly:
Many modern browsers support Gzip compression. Through .htaccess
, you can tell your server to serve gzipped HTML pages, JavaScript and CSS files (or any other text file, since images like JPG and PNG are compressed natively). You can use two approach, depending on your server settings, just add on bottom of your .htaccess:
- PHP flag method (compress only php served pages):
# via-PHP compression (only with compatible browsers)
php_flag zlib.output_compression On - Apache mod_deflate method (preferred method where available)
# Enable file compression by MIME type
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
# Exclude Not compatible browsers (uncomment to activate)
# BrowserMatch ^Mozilla/4 gzip-only-text/html
# BrowserMatch ^Mozilla/4\.0[678] no-gzip
# BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
Using this method, you can compress HTML pages, JavaScript, CSS files specifying ;MIME type
See also / references
10 responses to “Improve Drupal performance”
[…] Improve Drupal performance By chirale Here some tips to get an A with Drupal 5.x. Step 1: Fewer HTTP requests:. Aggregate CSS (/admin/settings/performance); Aggregate JS with Javascript Aggregator (experimental). To avoid JavaScript errors in some modules (ie TinyMCE), … chirale – https://chirale.wordpress.com […]
Thank you very much, I have just applied at my website.
Data Savings: 75.86%
good article man.
keep it up.
Thanks for your advice! It helps me a lot!
And what about improving performance of the admin pages?
It is a most important thing for me now.
Hi Gold, on Drupal 6.x in many cases disabling “Update status” and all “Developement” (e.g. Dev, Coder, etc.) modules on a production website could improve performances for an administrator user. Remember that page caching systems are effective only on anonymous users’ browsing.
Memory consumption is another hot topic for performance boost: on Drupal memory consumption: some tips you can read more about that. Thanks for visiting and Happy drupalling!
Excellent job! Many thanks!
Keep it up!
How often do you think about improving performance of Apache2 httpd web-server?
“It’s too slow”, “we need more powerfull server”, etc.
Telling the truth, default settings of Apache2 aren’t good and it’s best to try optimizing those first, before thinking of more advanced solutions.
Mod_deflate in apache2 is pretty much the same as mod_gzip in apache1.3, and mod_deflate is included with the apache2 source package. Both modules allow compressing of the apache server on the fly
http://railsgeek.com/2008/12/16/apache2-httpd-improving-performance-mod_deflate-gzip
Thanks Mikhailov: I know that lower compression are used primarily to reduce CPU workload. Since Drupal has his own Javascript and CSS cache system, aggregating many files into a single one, an interesting system is to gzip that file only one time, redirecting request to this instead recompressing it at any request.
Here some howto (drupal 5.x and 6.x):
http://drupal.org/node/249211
http://drupal.org/node/249211#comment-900656
http://kaioa.com/node/78
I tried your suggestion 2. Apache mod_deflate method (preferred method where available)
Now I get hundreds of lines of errors like this in my apache error log:
[Fri Mar 06 14:03:04 2009] [error] an unknown filter was not added: DEFLATE
Any ideas?
Thank you very much this is wonderfully helpful. I went from a D to a B in Y-Slow- hah