How To: Compress web page data transfer with mod_deflate and mod_headers

Since I rebuilt my VPS the other day there a number of tweaks and changes I need to make which can speed up the website – one of the easiest ones with the biggest effect on pageload time is to have apache serve compressed versions of pages to users. Here’s how to do it, and test that it’s working.

Enabling mod_deflate and mod_headers

Chances are good that you already have mod_deflate and mod_header on your server (they typically come with the apache install) – so all you need to do is enable them. To do so, open your main apache config (for example, on mine it’s /etc/httpd/conf/httpd.conf and uncomment the LoadModule lines for each module, so that they end up like this:

With that done, you can head down to the bottom of the config file and add the following section to enable compression of all html, css, js, xml and such.

Restarting apache and testing it out

With those changes made, save the file, restart apache (for example, via: sudo systemctl restart httpd.service if you’re on a systemd-using machine), and then go to: http://www.whatsmyip.org/http-compression-test/

Plug in your URL and hit submit, and you should see some good news similar to this:

A page saying that we are successfully serving compressed webpages.

Very nice =D

Many thanks to: brighterlamp.com for the original article this one is based on.

Stray random quotes plugin refresh fix

Pre-Amble

Back in the day, I decided to use the stray random quotes plugin to place a random quote at the bottom of each page. It worked, and still does. Only, if you clicked on a quote it didn’t refresh – instead it said ‘Loading…’ and then placed an error in my web server log like this (not that it looked like you could even click on a quote anyway – the mouse cursor didn’t change to the ‘pointy-finger’):

I’ve known it didn’t work for ages, but not especially cared, and then this morning I’m putting off doing actual work, so I fixed it.

The Fix

The problem was that like many people, I’ve moved the file wp-config.php outside of the web-facing folder, so instead of living in /var/www/ it actually lives in /var/. Stray_random_quotes tells you that if you’ve moved your wp-config.php then you need to provide the modified path in stray_ajax.php itself, right near the top – so do so!

The first two lines of stray_ajax.php should now read:

That should do ‘er – now, stray_ajax.php should be able to call wp-config, which will allow it to call get_stray_quotes().

Further

When monkeying with wp-config, I saw that it was calling wp-settings, but the call was failing because they expect to be in the same folder, only as mentioned – wp-config.php is up a level from wp-settings.php (which holds no credentials), so, to fix this:

– Edit /var/wp-settings.php and right at the bottom, change the path to the wp-config.php file to be:

How To: Disable the Proofreader in WordPress

I liked the WordPress proofreading service at first, but then it started telling me that basically everything I wrote was wrong, and that I should dumb down every single post to include only words which lifetime readers of the Sunday Sport would understand. So I wanted to disable it – only I couldn’t find the option…

It’s under Users > Your-Profile

WordPress Proofreading Settings

If I’d thought of it as a per-user setting I’d have looked there – and admittedly, it makes sense for it to be a per-user setting.

But damned if I could find it.

One Million Hits – Hot Dang!

r3dux.org - one million hits
r3dux.org - WordPress Stats summary - Oct 2011
When I relaunched this blog on WordPress from the ashes of its PHP-Nuke incarnation back in April 2009, it was just meant to be a place where I could throw some notes about how to go about doing things, so if I ever need to do them again it’s all documented, and if it helps anyone else out whose in the same predicament then all the better. And you know what? That strategy seems to be working out pretty well!

r3dux.org - Google Analytics - Oct 2011
r3dux.org - Google Analytics - Oct 2011
I don’t blog about what I had for dinner, I just post up some notes and how-to’s, along with some pictures and music, and maybe some life related stuff if I think it might be interesting to others, or if I just want to keep a record of what’s going on. And now, 31 months after launch, I’ve reached seven figures worth of hits (not including my own visits) according to WordPress Stats – Woo-Hoo!! Even Google Analytics‘ stats (which I’ve generally found to be lower than the WordPress Stats figures) shows just over a million page views – so maybe I really hit the magic number a couple of days back, but either way I’m absolutely psyched that I’ve managed to get to this point!

As for traffic sources, a large part of that has been driven by StumbleUpon throwing visitors my way, which is something I would never have guessed would happen. When I started up I thought the majority traffic would come from search or links in forums, and I do get a fair amount of that, but the real figures, all the massive spikes you can see below? All from StumbleUpon…

r3dux.org blog stats - October 2011. StumbleUpon kicks like a mule...

All this isn’t to say that the 1,000,000 page views means 1,000,000 articles read – I’m sure at least half of it all has been people just clicking through Stumble!/Stumble!/Stumble! – and if you look at the Analytics data top-left you can see some interesting trends such as with higher traffic comes lower Time-on-Site (as a result of stumbling here, and not being interested!) – but at least some of it, maybe 10% to 15%, has been directed search, i.e. people looking for something, and finding it. And that’s still a large number! Even skipping over the outliers you can see a definite upward trend of views against time…

So where next? Onward and upward, I guess! I’ll try to post interesting, useful things – and I’ll see if anyone reads them! There’s a whole heap of JSP/Servlet coding to be done over the coming months, as well as trying to put the Stanford AI knowledge to use, and no doubt I’ll be adding a whole heap of random that I couldn’t possibly predict right now. So yeah… it’s all very build it and they will come ;)

To wrap up, I’d just like to give my thanks to everyone who knows and supports me, whether family or friends, and to anyone who’s found or learnt or enjoyed something I’ve put up on this site: This exists for you, whoever and wherever you are.

And finally, the only song I could possibly place in a post like this…

More hits than playing blackjack with a deck of twos! Love it! ;) [ lyrics ]

Site Change Pending – Welcome to 2011

I managed to break this site the other day when the theme I’m using (Freshy 2) decided to use a different set of options. I obviously triggered it somehow, but I’ve no idea how – and then it all got confused about which options and CSS adjunct to use, and didn’t want to work with the customize plugin and… yeah, it all went a bit Pete Tong. Given that the Freshy 2 theme is unsupported and doesn’t really work that well past WordPress 2.7 (which is pretty legacy), it’s no wonder strange things have been just waiting to occur, but I’ve got it back to a semblance on sanity (as you might be able to tell since you’re reading this, and noticing it doesn’t look a million miles different from before – apart from comment threading, promise me you won’t look!). I even backed up the entire www folder three days before it all went to hell, but when I restored the backup it’s still shafted, so the Freshy options must be stored elsewhere (like in the database somewhere)… but anyway, I digress; it’s time to shake things up.

Kicking and Screaming

I started reading about CSS3 the other day, and began knocking up examples of all the cool things you can do with opacity and 2D transitions and stuff – and it’s awesome. I had absolutely no idea you could do such cool stuff without JavaScript or Flash, and if you apply it to the experience layer (as opposed to the core functionality layer), then even if people are viewing your site in older browsers it can gracefully degrade and leave those running some archaic IE variant none the wiser that should they be seeing the site in Chrome or FF5 or such it’s got a lot more swish. I might even try some HTML5 shenanigans…

This isn’t going to change the core content for the better (sadly), but if the medium is truly the message, then perhaps by giving the medium an overhaul and a good lick of paint I can emphasize the message to a certain extent.

I don’t want to even think about how much time I could waste on 3D transitions… the sky’s the limit, ya know?

Stepping Up

So, to get the site all sorted, I have a (not especially cunning) plan:

  1. Get an offline version of the site running locally so I can twiddle the hell out of it. [COMPLETE]
  2. Rip the Freshy theme to bits, and combine all the CSS and CSS adjucts (which get pulled in and override the core styles) into a single CSS file. [COMPLETE – 2011-08-08]
  3. Remove all the cruft from the Freshy CSS and PHP. And there’s a lot of it. Tons. [96% COMPLETE 2011-08-10]
  4. Rewrite the core layout utilising CSS3 and perhaps HTML5 elements to make it look beautiful. [60% COMPLETE 2011-08-09]
  5. Bask in the radiant glory of a modern, dynamic website. [PENDING]
  6. Write good articles =P [ARGUABLE]

Speaking of which, I’ll write an article on getting an offline version of a site running soon – it actually took me a couple of hours to get everything installed, configured, database suitably modified (to keep me on the local copy at all times) & imported into MySQL etc. But now I have, I don’t have to do surgery on a live site, and can thus afford to break the hell out of my local copy, because things tend to get a lot worse before they get a lot better, and this version will still be up and running in 99% “good enough” mode.

Honestly though, CSS3 is amazing – check it out. I can’t wait to see what I can come up with =D