How to Best Optimize Your Site

You have a site, or want to create one.

You want your site to uphold all best practices and standards so all search engines will love it, thus grant it a high location in their results.

You want your site to be speedy (for your user's sake and for the search engines').

Before putting down my 2 cents, let me point you to a prior article of mine in which I have recommendations for your site upgrade

Here are a list of suggestions accumulated over time.

Please note that many will view these suggestions as premature optimizations thus should be implemented only after you have many users etc or else it isn't worth it - they may be right...


Hosting Web Environment

  • Don't use Shared hosting! (Not even a reseller account) - they suck and from time to time there are shameless downtimes !!!, You should at least go for a VPS if not something better, and nowdays they aren't that expensive, several educated recommendations
    • Vultr
    • KnownHost
    • DigitalOcean
  • OS, well, admittedly, I don't know enough here, but from whispers on the web I would choose them in this order
    • Centos
    • Ubuntu
    • Debian
  • Internet Protocol - Http is a very old protocol, a much faster alternative was created by google called SPDY, which is now replaced with a better alternative which is HTTP2
  • Web Hosting, although the apache web server has been around for a very long time and most people choose it as the default web server, it seems that Nginx enjoys better performance, there are several aspects worth noting though
    • No htaccess file in Nginx (use nginx conf file instead which is mych more optimized)
    • Tweak Nginx to work nicely for your site as the OOTB configurations aren't always best for all sites.
  • Hosting Admin Panel, Now that you chose not to work with a shared hosting, then you should install an admin panel (like CPanel) on order to control your nginx web server
    • Webmin / Virtualmin with Authentic or BW theme
    • ISPConfig ?
    • Ajenti ?
  • PHP alternative, barring compatibility issues (some sites won't work well with php alternatives, like some wordpress plugins etc), it is highly recommended to change from php 5.6 to a better php renderer, my recommendations are as follows
    • PHP7 - Much faster, and even if compatibility isn't fully supported, it will be, so if you are running a CMS and a plugin isn't compatible, I suggest finding an alternative to the plugin rather than for php7 (and a supported plugin will upgrade itself to support php7)
    • HHVM - This is a PHP renderer by Facebook which is faster even than php7, but I recommend php7 over this one as compatibility issues might spring (with no future plans to fix the site to support hhvm) and the speed increase over php7 isn't significant.


Wordpress Tweaks

  • For best performance, static pages are the fastest serverd web assets (much faster than server rendered php etc), If you need a CMS (Content Management System) then prefer a flat file CMS like GRAV
  • Wordpress is the goto for CMS sites as it already has a huge plugin base, I will give my recommendations assuming you are using Wordpress
  • For any site using MySql, change it to the faster MariyaDB, it should be a seamless change as MariaDB has the same API as MySql, but you will gain a faster DB
  • For wordpress sites, the best table engine should be innoDB, or even better in MariaDB use the xtraDB
  • Disqus comments instead of wordpress comments


Security

  • Security handling is a must as a site with low security will be hacked and viruses will be uploaded to it / users will be directed to bad sites, bandwidth will be exceeded and your site will go offline, or simple DDOS attacks will just crash your site
  • First layer of security should be handled by the server thus saving time and bandwidth of requests arriving to the actual site and a plugin defeating them
  • Fail2ban should be considered as well as others (more research should be done here)
  • HttpBL (Project HoneyPot) - can it be integrated to NginX ?
  • Bad Behaviour which has a wordpress plugin (Here you can integrate the above httpBL)
  • 6G Firewall which has a wordpress plugin
  • Akismet for wordpress comments
  • Blackhole wordpress plugin (ingenius spam bot eliminator)
  • Another good Wodpress security plugin can be Wordfence


Site Architecture guidelines
  • SSL is the right way to go - for the whole site
  • Site should be Schema.org compatible
  • For best site performance (and google tagging) use AMP for site frontend
  • All site assets should be thrown into an optimizer which will minify/compress (lossless) etc all assets, for this just dump the whole site folder into FileOptimizer
  • GZIP compression should be enabled on the server
  • Try to use only the best built plugins from the wordpress repository, for that purpose, use the Jetpack by Automatic which is a pack of plugins which you know are optimised in the best way as Automatic created them, which means that they are probably coded better than the alternative.


Caching

  • Use a caching system to serve static pages instead of dynamic pages
  • Compare server caching vs or with wordpress plugins caching
  • Wordpress caching
    • Super Cache
    • W3 Total Cache
  • Server caching
    • OpCache for PHP caching (embedded in php, no config needed in WP)
    • FastCGI (better than varnish (which also doesn't support https)?) for page caching
    • Memcached or Redis for DB caching

    • Nginx + FastCGI Cache + TMPFS disk cache or Memcached
    • Others ?


Conclusion

For the conclusion I will setup two imaginative sites

Fastest Site:
Infrastructure: VPS (Vultr), Centos, NginX, Webmin (as a panel), PHP7, Server Cache
Site: GRAV CMS, Disqus comments, Bad behaviour + blackhole + 6g firewall for security, All assets optimized, SSL, Schema.org, AMP (frontend)

Fast ans simple to maintain site:
Infrastructure: VPS (Vultr), Centos, NginX, Webmin (as a panel), PHP7, Server Cache
Site: Wordpress (MariaDB using Xtradb engine), Automatic plugins (AMP, Forms, Photo gallery, Akismet etc), Security plugins, BB + 6g + Blackhole + Wordfence, SSL, Schema.org

Comments

Anonymous said…
For optimizations look at the following links:
Official wordpress suggestions

Another article about optimizations

Popular posts from this blog

How to read Android apk contents

Start Working with AutoIT

SCummVM for Android