Skip to main content

This is a new website theme. Help me improve it and give your feedback (opens in a new tab).

Webpage Load Times

Published:

Tags:

Web Sysadmin
This blog post is more than two years old. It is preserved here in the hope that it is useful to someone, but please be aware that links may be broken and that opinions expressed here may not reflect my current views. If this is a technical article, it may no longer reflect current best practice.
gordonjcp ╡ irl: jesus christ, scale your fucking images

My last post about the adventure to the Donmouth Local Nature Reserve turned out to have a total page size of 69.2MB. Oops.

I’m new to using Ghost as a blogging platform, and in the past blogging platforms have scaled images for me. It turns out that Ghost does not do this. There is currently an open issue on GitHub discussing this but I don’t think this feature will be appearing at any point soon.

Google have an Apache module, PageSpeed, that has some image processing features in it. I think actually, as image processing is a common task for web applications, it makes sense for the web server to be doing this as opposed to every application implementing its own methods.

Installing The Module

The PageSpeed module for Apache can be downloaded from here. They provide a .deb archive for Debian and so I went with this option. I wasn’t too happy about following their installation instructions though, so I did:

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.deb
sudo gdebi mod-pagespeed-stable_current_i386.deb

Their instructions tell you to install the package with dpkg and then fix the dependency issues with apt-get afterwards. I don’t like to leave apt in a broken state for any length of time and so I used gdebi, which will resolve dependencies and install the required packages before installing the new package. If gdebi is not available on your system, you can install it with:

aptitude install gdebi

The Module In Action

After restarting Apache, the module was already installed and ready to go. It was minifying the CSS and JavaScript, but the big thing was the images. I wanted them to be resized from 4096x3072 pixels to something that might actually fit on an average screen in one page.

After some playing with this, no luck. It seems that in order to play with images the module needs to be able to see them in the filesystem. As Apache is reverse proxying Ghost, the module has to fetch these over HTTP and so there’s nothing it can do.

This was dissapointing.

The Workaround

As it seems that it’s not going to be possible to have dynamic image resizing on the fly, I went with another less elegant method:

mogrify -resize 900 DSC_*.JPG

I guess until Ghost is capable of doing image resizing on it’s own, I’ll have to just put a bit more thought in before uploading images with far higher resolution than is necessary. Maybe there’s a reason this functionality wasn’t in the web server and applications always did it their own way.