I decided to rebuild syslog.tv as pure HTML using RST and Pelican and rebrand it as kura.gg.
In doing so I decided I would go all out and use SPDY and ngx_pagespeed (mod_pagespeed) for fun to see exactly what I could do.
Sadly no version of nginx has been officially released with SPDY or ngx_pagespeed enabled, you can compile nginx from source to enable SPDY so I thought I would go ahead and do it, releasing some Debian packages in the process.
After compiling nginx from the source package available at the Ubuntu PPA, I decided I would go further and compile in ngx_pagespeed.
Installing
I have released the 4 required debian packages below (please note they are only available for amd64);
You can install them by simply running:
sudo dpkg -i nginx*.deb
If you already have nginx installed, make sure to remove it first.
You may receive an error due to missing dependencies, to fix this run:
sudo apt-get install -f
Configuring SPDY
SPDY only works over HTTPS, so bare that in mind. All you need to do is enable SPDY in your server configuration as below.
server {
listen 443 ssl spdy;
server_name kura.gg;
# ...
}
It’s a simple as that, you can test this using the Firefox and Chrome extensions that show you websites with SPDY enabled.
Configuring ngx_pagespeed
To enable ngx_pagespeed you first need to create a directory that it can write cache files to.
sudo mkdir /var/cache/ngx_pagespeed/
sudo chown www-data:www-data /var/cache/ngx_pagespeed/
Once this is done you can enable ngx_pagespeed in your server configuration as below.
server {
# ...
pagespeed on;
pagespeed RewriteLevel CoreFilters;
pagespeed FileCachePath "/var/cache/ngx_pagespeed/";
pagespeed EnableFilters combine_css,combine_javascript,remove_comments,collapse_whitespace;
# ...
}
The three filters that are enabled do the following:
- combines CSS <style> elements in to one,
- combines multiple <script> elements in to one,
- removes all comments from HTML and,
- removes additional whitespace from HTML excluding <pre>, <script>, <style> and <textarea> elements.
You can test this by simply viewing the source code of your website and seeing all of the HTML compressed.
You can find more information on filters here.