// 07.Feb.2010

PHP Caching to Speed up Dynamically Generated Sites


// 06.Feb.2010

WordPress, Caching and index.html

I became aware of an annoying little glitch on the Urban Mainframe yesterday. It seems that WordPress, on which this site is running, doesn’t handle the URL http://example.com/index.html on an unmodified install (I’ve confirmed this on a handful of other WordPress sites). This is significant because index.html is a special file on many web-servers, often being the “home” page of a directory on the server. Without special handling, a request for index.html on a WordPress installation generates a 404 (file not found) error — which is obviously something we don’t want our visitors to be presented with.

In my case the impact of the glitch was magnified because I employ a quite aggressive caching policy on this website — and yesterday an unlikely combination of factors resulted in my 404 error page replacing my home page for a complete cache cycle. It went something like this:

  • cached “home” page expires
  • next “home” page request is for http://urbanmainframe.com/index.html
  • index.html file request results in a 404 error
  • 404 error page is cached
  • all subsequent requests for http://urbanmainframe.com/ — and other “home” page URLs — return the cached 404 error page until the cache is next invalidated

Quite a serious glitch then!

There are two things that shouldn’t have happened here.

  1. Requests for index.html should not result in 404 errors.
  2. Error pages should never be cached.

I resolved the first issue by adding the following snippet of code to the very beginning of the 404.php file in my WordPress theme:

<?php
if ($_SERVER['REQUEST_URI'] == '/index.html') { header("Location: http://urbanmainframe.com/"); exit; }
?>

For the second issue I’ve filed a bug report with the authors of W3 Total Cache, which is the caching system I use here on the Urban Mainframe.


// 27.Jan.2010

Unify: A Fantasy Fulfilled

Ever since I first started making web pages, I wanted a CMS that would allow me to make content updates by simply going to my website and changing the content right on the page. My fantasy was that this system did not require me to know any programming language or tagging system beyond HTML and CSS and it didn’t require me to play with a database. In my fantasy, the system took minutes to implement and my clients could use it as easily as I could.


// 27.Jan.2010

Unix Turns 40: The Past, Present and Future of a Revolutionary OS

After four decades, the future of the operating system is clouded, but its legacy will endure.

Regardless of the ultimate fate of Unix, the operating system born at Bell Labs 40 years ago has established a legacy likely to endure for decades more. It can claim parentage of a long list of popular software, including the Unix offerings of IBM, HP and Sun, Apple’s Mac OS X and Linux. It has also influenced systems with few direct roots in Unix, such as Microsoft’s Windows NT and the IBM and Microsoft versions of DOS.

The [Association for Computing Machinery] may have said it best in its 1983 Turing award citation in honor of Thompson and Ritchie’s Unix work: “The genius of the Unix system is its framework, which enables programmers to stand on the work of others.”


// 27.Jan.2010

Monitor Applications, Processes and Files in OS X with opensnoop

Using the command line tool opensnoop you can track any Mac application’s (or system process’) usage of the file system. This is a very handy tool for administrators and troubleshooting! The simplest way to use it is as follows:

sudo opensnoop -n Safari

You can also track a specific file, and what is accessing it, like so:

sudo opensnoop -f /etc/hosts

Tracking a specific process is as simple as just specifying the process id:

sudo opensnoop -p PID

opensnoop will keep tracking the file until the process itself is ended, so just hit Control-C in the Terminal to stop opensnoop from running. In case you’re wondering, opensnoop is based on DTrace, a popular UNIX tool.

[via]


// 27.Jan.2010

Using LaTeXiT to Display Math Formulas

Would Will Hunting use OS X? He might now:

TeX is a typesetting standard that, among other things, allows you to typeset complex math formulas. One flavour of Tex is LaTeX, for which LaTeXiT serves as a front-end on Mac OS X. Using LaTeXiT, one can drag and drop complex math formulas to a number of apps — Pages, Keynote and TextEdit, to name a few.


// 14.Jan.2010

Improve Multi-country Support in Address Book

Fixing Countries in Address Book: Winfred van Kuijk presents an awesome plugin he has written which addresses (pun intended) two significant issues with OS X’s Address Book multi-country support:

  • country names: you no longer have many variations for country names (so: all “United States”, instead of many variations like “USA”, “US”, “United States of America”);
  • country address formats: it tells Address Book to use the formatting that belongs to that country (e.g. [van Kuijk’s] default format is for the Netherlands, which means for US addresses that state is missing and zip and city are switched).

// 13.Jan.2010

AppZapper: Cute, But Pointless UI

Rubbish bins
Photo Credit: Trash Your Gifts by Euphoriefetzen

Everyone’s favourite uninstaller for OS X, AppZapper, recently generated a bit of a buzz as it metamorphosed into version 2 and acquired a slick new interface. AppZapper also seems to have grown beyond being a simple uninstaller, several pundits are now describing it as an “application manager.”

As an application manager one can view one’s applications in a pretty interface, sort them with various filters and even store their license codes within AppZapper. I have to say that license code management seems to me to be an odd addition to an uninstaller. There’s no synergy between the tasks of uninstalling applications that are no longer required and retrieving licensing details for those that are.

But that’s not my biggest issue with AppZapper. To me, whilst the application itself is extremely useful, the interface is completely redundant and, pretty as it is, it shouldn’t be there at all.

Continue Reading…


// 02.Jan.2010

Get Cached Images from Your Visitors

Following Jeff Atwood’s recent catastrophe with his Coding Horror website, he asked his readers if anyone could help with or suggest ways in which he might recover the images that had been lost when his web-server’s hard disk went off to its final resting place. One of Atwood’s readers came up with a remarkably elegant and clever way of recovering some of those images from the browser caches of Coding Horror readers (complete with code samples). This is the sort of hack I love: clever, imaginative, effective and single-minded. Awesome stuff.

Another reminder folks that we should all be obsessive about doing our backups and restores.


// 31.Dec.2009

10 WordPress Dashboard Hacks

A large part of my professional work involves the build and deployment of WordPress-based websites. Now as any designers/developers among you will appreciate, it can be extremely annoying frustrating to sign off a build only to come back later to see that your client has (inadvertantly) messed things up because WordPress has placed too much power in their hands.

I was delighted then to read “10 WordPress Dashboard Hacks” because there are some really useful code snippets presented therein:

  • Remove Dashboard Menus: At last I can remove certain menus from the client’s view — whilst obviously still leaving full control for the Admin user
  • Define Login and Dashboard Logos: Great for branding.
  • Disable the “Please Upgrade Now” message: I never want my clients to do this. I think this is one of my responsibilities.
  • Customise Dashboard Widgets: Again, it’s about keeping control. Not exposing the client to things which could be hazardous.
  • Provide Help Messages: Because they’re helpful (if done correctly).

Some of these are definitely going to be rolled out on to some of my client’s sites in the near future.