How to Speed Up Joomla

by Mike on February 23, 2009 · 3 comments

in Web Server

There is no secret that the code that is Joomla takes time to generate when a request is made.  Sure you are using PHP and mySQL but as your site grows and as you add extensions you may see the site slip into the 5-10 seconds for loading.  That is really tough for users, though as you look around lots of sites have 10 seconds of ads loading.  But, if you care about your users you will want to optimize the Joomla code and balance that will providing content and ads to keep things going.   This tutorial is the result of several days work I did on a Joomla site trying to get it to load faster.  Here is what I found.

1. Don’t Buy New Hardware
I did an evaluation of several sites and machines with Joomla to try to see if hardware was the issue, basically it was not.  In fact, if you have sufficient memory it is unlikely that your hosting is suffering from a slow CPU, I/O, disks or network….at least in general.  Some hosting sites of course overdo so that you do have those issues, but if you own the hardware, you are pretty safe in that it is not hardware that is your problem.  It is the code!

2. Create a Baseline
The first thing to do is create a baseline for testing to you can make some comparisons.  The baseline I made was a site with Joomla 1.5.9 and Community Builder as the major extension.  No cache and no gzip was used for the baseline. I used this site to do the testing:,com_performance/Itemid,52/


You can see a number of images were on the site as well as code from Joomla.  This is an example of the baseline so that I could compare as I made adjustments.  The 4.3 generation time was one thing I wanted to reduce.  Generation time being the time it takes for Joomla to respond to the request…


3. Cache On, Google Ads Off and Reduced Images.

Here is the statistics for these settings which are a bit strange as you would think the cache might help but it makes it worse.  By the way I noticed a number of people said the same thing when they used the default cache.  Generation time increased.


4. No Cache and .htaccess moved to httpd.conf
When you place the .htaccess file information in the httpd.conf file  the server does not have to look in every folder for .htaccess, which requires 4 lookups for each request, I moved the .htaccess content to the main httpd.conf file and placed it in a Directory which actually reduced the time for generation by 20% in my testing.

<Directory /var/www/html>
#  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#  mod_rewrite in use

RewriteEngine On

#RewriteRule ^/(.*)-(.*)/(.*)\.html web/index.php?app=$1&ns=$2&ref=$3 [L,PT]
########## Begin – Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
########## End – Rewrite rules to block out some common exploits

#  Uncomment following line if your webserver’s URL
#  is not directly related to physical file paths.
#  Update Your Joomla! Directory (just / for root)

# RewriteBase /

########## Begin – Joomla! core SEF Section#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
########## End – Joomla! core SEF Section


5. No Cache but gzip the Content

The advantage of using gzip is the content is smaller over the wire, so that you can do more with bandwidth which is certainly a plus.  However, you can see the generation time almost doubled.



I tried everything….turning cache on and off, turning gzip on and off, reducing images, every combination.  In the end, this is what I did.  I decided that bandwidth was important so I now use gzip which compresses your page as it is on the network and your browser does the work to uncompress it.  I also, enabled the cache which helped witht the speed.  What made the most positive differences was eliminating the .htacsess files, saved 20% on average.  Certainly not perfect but at least I gave it a shot.   By the way, WordPress generates in 1/3 of a second compared to 4-8 seconds for Joomla.


ssalvekar March 12, 2009 at 6:18 am

Gzip on in joomla does have good effect on joomla performance along with cache on. . Even they have given a comparative chart on joomla performance with or without gzip / cache / template option etc….

Suddenly Stupid August 21, 2009 at 6:15 am

Nice article. I’ve employed Joomla/Mambo for 6 years on a shared server. The backend performance is abysmal. The metrics you posted have me reconsidering a major joomla launch I am building for a non-profit organization. Forcing volunteer content providers to wait on the clunky backend is probably a deal-breaker in the long run. The .htaccess / httpd.conf tactic is interesting … I haven’t run across that idea in the Joomla forums.

{ 1 trackback }

Previous post:

Next post: