Website speed (or “performance” as we like to call it) can be a tough and complex area and can be very difficult to get right without experience. However, there are some basic techniques that give big returns and in this article we’d like to share some things that normally give quick wins when your website is slow. Using these tricks alone we’ve seen many websites go from display times of 30 seconds to 3 or 4 seconds, just to give you an idea of the results possible for really slow pages.
This article is written mainly as a management overview of performance, and it also contains some quick pointers for technical people.
- Website download time
- Website “first byte” time
[code language=”php”]#Start Gzip
[code language=”php”]#Start expire
ExpiresDefault “access plus 1 week”
- WP Supercache – an easy to install plugin
- WP-Rocket – probably the easiest caching plugin, very simple to install
- W3 Total Cache – the most complex of the performance plugins, it also provides good CDN integration. Be warned, it’s complex!
As this is an overview article we won’t go into these plugins in depth other than to say that very detailed instructions are available on how to install them if you do some quick searching.
- Use a different webserver stack – we prefer LEMP for speed, Apache degenerates badly under load
- LEMP/Nginx can deliver static files 10x faster due to use of kernel optimization hooks
- PHP accelerator – retains compiled code in memory, approx 2x benefit depending on site
- Use a CDN to move the work for static files onto a fast-dumb architecture
- Use the above techniques – File compression, Expiry etc
- Consider Google optimize – can work well, but can increase CPU load
- We tend to use a faster database than MySQL – this can give a 2-3x benefit
- Avoid needless database queries, and make sure any queries you do are not slower when the database gets bigger. (See next point!)
- Use performance profiling plugins to help reveal any problems with SQL queries or plugins you may be using on a site (eg NewRelic)
- Use the available WordPress debugging plugins to make life easier for yourself
- Try to cache slow operations and only re-run them occasionally. eg: Don’t re-run complex queries every time the home page loads!
- Always use a cache when you develop a site (so you can fix problems as they arise)
- In Australia, avoid the Google Hosted Library versions of things like jQuery as the lack of AU-based POP can add a whole second to your site load time (per file!)
Of course, there are many other things that you should be aware of and we highly recommend a visit to the webpagetest.org performance measuring tool as you develop your code. It’s too late to test right at the end as it’s much easier to fix problems as you go; and progressive checks will help you improve your website optimization skills quickly.