Improving performance

Do you have the idea that your website is slow or rather not optimal? Have a look at these pages with tips for improving the performance of your website.

Contents

General tips

When your website is loading less quickly than you would like, in most cases the cause can be found by the steps below. Check at least the following possible causes.

Your own internet connection

This can be slower than you are used to by temporary activity. Cable internet is often slow during peak load. Also, when you or your colleague is downloading large files this can influence the speed. speedtest.net can give insight in your current internet speed.

External factors, such as the usage of other data sources

Does your site get information from other sites that are possibly slow? Are there embedded videos, widgets, live webcams and so on? An external statistics program such as Netstat can also cause speed reduction.

So, check your site first on a different PC or internet connection to test the connection. Next, look for possible problems in the configuration of your site, or in your hosting environment. Possible internal factors are addressed below.

Internal factors, such as errors in the server-side application code

There are often problems with the speed of your site by excessive usage of plug-ins in your CMS system. Be anyhow scrupulous and frugal of plug-ins usage and start especially with your plug-ins when searching for the possible cause. Maybe there is also a loop in a block of code, or or, when a database is running on your site, maybe there is a "wild query", by which the whole system reduces in speed.

Useful tool-tip: Developer tools!

When you have ruled out that you have a local problem then the developer tools can be useful to improve the performance of your site. This program helps you find out on which point during loading of your site the delay occurs. Developer tools are available in Firefox, and Chrome & Chromium.

You can find the Developer tools in the menu of your browser. The network tab is the most useful tool to investigate where delays occur. You can also bring up this tab with a keyboard shortcut, in Firefox that is done with [CTRL] + [SHIFT] + [E] and in Chrome and Chromium it's done with [CTRL] + [SHIFT] + [I]. Usually you will have to refresh the page after opening this menu to start investigating.

Advanced tips

Below are some tips to considerably improve your website-performance. Some tips do require a major modification of the configuration of your site so those should not be executed on the live version of your site, or only on the moment that you accept possible downtime. Contact Greenhost for settings that you cannot modify by yourself through the Service Centre or the control panel of your CMS.

7 general tips for large speed gains

Choose the right hosting package

At Greenhost the limit of available PHP memory is linked to the hosting package. This means that a heavy, complex site on one of our Personal packages runs possibly slowly or otherwise not well.

Use recent software versions

Make sure that you are always able to install the latest updates of your CMS package, or make sure that your site updates automatically. It can also be sensible to remove modules, add-ons or plug-ins that have not been updated for longer than a year, or replace them.

Have a critical look at installed modules

Check that you really need all modules that you have installed. All modules that you install cause extra overhead and as a result they are a possible source of delay. Moreover, some exotic modules are often not well programmed or they can contain mistakes, by which your webshop becomes less stable. Some modules might provide performance-wins, but they could do things all over again just as well. If you have configured your caching well, installing an extra caching module is often not advisable.

Switch to the newest PHP version

Using the newest PHP version often means a considerable speed gain for your site. Check at this point that no problems arise on your site. Also see this helpdesk page.

Configure mod_deflate to compress content

Via the Apache module mod_deflate you can compress your content before it goes to the browser. This can result in a considerable speed gain. Add the following lines to your .htaccess config file (remove other references to mod_deflate!):

.htaccess

1
2
3
4
5
6
7
8
9
10
11
12
<IfModule mod_deflate.c>
    # Insert filter on all content
    SetOutputFilter DEFLATE
    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    # Don't compress images (or gzipped files....)
    SetEnvIfNoCase Request\_URI \.(?:gif|jpe?g|png|gz)$ no-gzip dont-vary
</IfModule>

Configure expiry headers for better cache control

By default there is no use of browser-caching. You can enable this via mod_expires. Add the following configuration lines to the .htaccess file in the root directory of your site (remove other references to mod_expires!)

.htaccess

1
2
3
4
5
6
7
8
9
10
<IfModule mod_expires.c>
    <FilesMatch \.(png|gif|jpg|js|css|js\.css)$>
    # Enables generation of 'Expires' and 'Cache-Control' headers
    ExpiresActive On
    # Sets default expiration time
    ExpiresDefault "access plus 1 month"
    # Disables entity tags (ETags)
    FileETag None
    </FilesMatch>
</IfModule>

Set up aggregating JavaScript

The combining (aggregating) and cropping (minifying) of JavaScript files on sites built with a CMS such as WordPress or Magento is not superfluous. Magento offers the possibility to combine JavaScript files to a larger file before it is sent to your browser. Combined with gzip-compression (step 7) this can lead to considerable speed gains. For WordPress or other CMS packages you need to find a suitable plug-in or add-on.

+5 extra (Magento only) tips

Caching and Indexes (Magento only)

You need to enable caching and indexes always at every installation of Magento. You can do this by ticking all checkboxes in your Magento control panel under system > cache management and system > index management and save your changes.

Configure a flat catalogue category in (Magento only)

In your Magento management panel you can tick the option 'Use flat catalog category' under system configuration > catalog. This results in indexing your product categories. Only if you have a large webshop (at least 1000 products), ticking the 'Use flat catalog product' also brings speed gains - otherwise it is better to leave these options disabled. NB : with older versions of Magento < 1.4.x you also need to click under Cache Management on rebuild catalog index.

Delays after some time? (Magento only)

In Magento versions < 1.4.x there is a bug by which the control panel is functioning slower and slower. The workaround for this problem is to log in with SFTP and remove everything under the directory /domains/uw/shop/var/cache/*. In this way you wipe the whole cache clean. Be mindful that you are in the right directory! Sometimes this action can be useful if you have the impression that the frontend has become slower. It cannot hurt, regardless the version of Magento, to clean the cache from time to time. After this you can generate the indices again and refresh the caches via your Magento administration panel under 'Cache management' and 'Index management'.

Save sessions in the database (Magento only)

Save sessions in the MySQL database and not as files. This creates a faster processing of sessions. In the file app/etc/local.xml you can edit the file:

app/etc/local.xml (old)

1
2
3
<session_save>
  <![CDATA[files]]>
</session_save>

into

app/etc/local.xml (new)

1
2
3
<session_save>
  <![CDATA[db]]>
</session_save>

Setting up a cron job for Magento maintenance (Magento only)

This does not directly cause speed gains, but it lets Magento do automatic maintenance tasks. Go in the Greenhost service centre to the section 'Periodieke taken (crontab)' and add the following task that needs to run every 15 minutes:

1
/usr/bin/php7 /domains/yourdomein/subdomein/path-to-shop-root/cron.php

So, as your first argument you give the complete path to the cron.php file in your shop root.

General wisdom: also use webdeveloper-tools and our Apache-logs

You can keep tweaking your website installation without end, but often bad performance is somewhere else. Does your site load external elements of another site, for example? Do you use images with a larger filesize than necessary, complicated database queries in customised PHP code? Are there JavaScript errors when loading your site? Have a critical inspection of every part of your website and especially tools such as Firebug and variations such as GTmetrix or Firefox Web Developer can be very useful.

In the Service Centre of Greenhost you can see the Apache error logs under Hosting – Logs at 'Webserver error messages'. There could be useful messages that indicate possible problems with your site.

Advanced: full page caching for the power user

Experienced web developers can make use of a so-called full page cache module. Such a cache module tries to improve the loading speed of your website by generating non-dynamic elements for once and direct these to the browser. In doing so you often need to configure which elements you do and which ones you don't want to have in the cache. This is why this process cannot be automated. But if you do look into this, you can get more speed gains in this regard. Via a search engine you can find several full page cache extensions for Magento. Some of them are free of charge.