Headline News
GoPro Returns with New Range (September 26, 2016 7:31 pm)
TRAILER: Doctor Strange (April 13, 2016 8:23 am)
TRAILER: Dawn of Justice Trailer 2 (December 3, 2015 6:25 pm)
Luther Season 4 Returns to the BBC (December 2, 2015 9:13 pm)
Sherlock Special (December 2, 2015 9:01 pm)

Website optimisation

April 9, 2014

The first thing I usually do once I have a website up and running is run it through GTMetrix to see if there are any major problems or anything I can tweak to gain a potential speed boost.

When I ran my GTMetrix on my site it initially it came back with a grade D. The problem was mainly due to my Nginx configuration. The first thing that came up is that I wasn’t serving up compressed files where possible. This was a fairly easy fix, I just added the following to my /etc/nginx/nginx.conf file, in the http block, which bought my grade up to a C.

# Compression
gzip              on;
gzip_buffers      16 8k;
gzip_comp_level   4;
gzip_http_version 1.0;
gzip_min_length   1280;
gzip_types        text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp;
gzip_vary         on;

The other main thing was that I wasn’t leveraging browser caching, so I added the lines below to my server block in /etc/nginx/nginx.conf.

# Browser caching
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires 1y;
    log_not_found off;

I also had a couple of images that GTMetrix suggested I could optimise further so it converted them for me and provided me a download link for the new versions (awesome!). This site now registers as a A/B grade, depending on which test you use. GTMetrix also suggested that I minify my CSS files, which I will do at some point but I am actively tweaking elements of the site at the moment so it is useful to have the CSS files in a somewhat legible format.