Web Design Latest Entries

Standalone Script for Clearing APC Cache

After upgrading WordPress to a new version, you might need to clear the APC opcode cache. Here is a simple script that you can store in the root of your website, for example, clearapc.php:

if (function_exists('apc_clear_cache') && $_GET['pass'] == 'secret') {
        if (apc_clear_cache() && apc_clear_cache('user'))
                print 'All Clear!';
        else
                print 'Clearing Failed!';
        print '<pre>';
        print_r(apc_cache_info());
        print '</pre>';
} else {
        print 'Authenticate, please!';
}

Then call the script via http://example.com/clearapc.php?pass=secret

Instead of using ?pass=secret, you might well call the filename something that is hard to guess: clearapc93920.php

Use AJAX for Cache Invalidation

Let’s have a site wide version number that is changed every time something is updated and cache needs to be invalidated. This number is stored in a simple text file. Cache keys are made up of Request-URI and this unique key, which is passed around in a cookie VERSION_NO.

On every page request javascript calls version.php?timestamp (which is never cached because of the timestamp), which using stat() reads the last modified timestamp of that text file and compares it to the value of VERSION_NO cookie. If they are different, a new cookie value is set, which in turn changes the cache key for all future requests, and the cache is invalidated.

The only thing I don’t know is how fast and resource hungry is the stat() call?

Update: or would it be better to use filemtime()? There is a comment which says that 1000 filemtime() calls take 0.0049 seconds, which I think is very reasonable.

PHP APC Potential Cache Slam Averted for Key

This server uses PHP 5.3 with PHP-FPM (FastCGI Process Manager) patch and APC opcode cache. Several minutes after activating APC, I noticed that some pages stopped loading. Turns out it was because of an APC timebomb bug which is when all cache writes got locked because of expiring cache entries and new writes happening at the same time. The temporary solution is to add apc.write_lock = 1 in php.ini.

Remove index.html from the URL

Some servers seem to automatically append index.html to all HTTP requests, which you can remove by placing this at the beginning of .htaccess:

RewriteEngine On # remove this, if you have it already
RewriteCond %{REQUEST_URI} index\.html
RewriteRule ^(.*)index\.html$ /$1/ [R=301,L]

I used this technique for a site that I built — ichomesforsale.com which is hosted at Godaddy.

The Unspoken Heroes of Web Design

While playing with the typography of this blog, I couldn’t appreciate enough the simplicity and elegance of Tahoma, it’s wider sister Verdana and beauty serif Georgia. All of those fonts were designed by one guy — Matthew Carter, English type designer born 1937, living in Cambridge, Massachusetts, US.

Portrait of Matthew Carter

Matthew Carter

Thomas Rickner

While you have probably heard of Matthew Carter, it’s unlikely that you’ll know Tom Rickner who hinted these fonts making them so easy to read at sizes with very few ink dots available to form their shape and guide the eye.

In the summer of 1994 Microsoft commissioned Carter and Rickner to design a new system font for Windows 95 which we now know as Tahoma. Here is the story of Verdana.

Once you’ll discover where the names of those fonts come from, you’ll never look at them the same way.

Semantics of Article Headline and Byline

Can you think of any reason why placing article credits before the headline, like this:

<p>August 18, 2009 by Author Name</p>
<h1>Title of the Post</h1>
<p>Post body goes here.</p>

is semantically worse than moving credits after the title:

<h1>Title of the Post</h1>
<p>August 18, 2009 by Author Name</p>
<p>Post body goes here.</p>

No Font Embedding, Please

The limitations of web design are also its most powerful features, when compared to print. Design is all about finding the best solutions within a specific set of scarce resources.

Fonts are designed to deliver information to the reader in the easiest and fastest way. Aren’t the fonts currently available on various operating systems doing this job well?

Remove Border from Image Links

For illustrating anchor links in some cases you might want to use bottom-border instead of a default text-decoration:underline. In order to achieve that, one would use the following CSS rule:

a { text-decoration:none; border-bottom:2px solid; }

which also adds border to the bottom of all linked images. In order to remove it, you would think that setting

a img { border:none; }

would be enough. Read more »

MediaTemple’s Disappointing Grid

Since the very first day this website has been hosted at MediaTemple. Back then it was a simple shared hosting account for a good price and a lot of good and well earned hype. Almost a year ago they started switching to a grid infrastructure which was said to be able to allocate enough computing power for every grid member no matter what the neighboring cells are doing. Read more »

Squeeze the Header of the New WordPress 2.7 Dashboard

Minimized header area of WordPress 2.7 I love the new WordPress 2.7 dashboard design even despite all the bad things that I have previously said. Back then it was only a prototype and probably even the core developers didn’t have a clear and complete picture of how it is going to look and work in real-word environment.

Now when it is one minute away from the prime-time, I applaud Jane, Matt and all the designers and developers behind the overhaul who carried out the work in such a transparent and feedback driven way.

For me it is the new icon-only-slide-right navigation bar that makes the whole administration section work so much better than I could have imagined. All the administration sections are only one click away. Navigation takes up only 40 pixels of the cheap vertical space and thus saves much of the expansive vertical area where things get done. The result is truly amazing and it makes me wonder if anyone really knew it will turn out to be this good. Read more »