Toxic Elephant

Don't bury it in your back yard!

How to Get Apache and Typo Page Caching to Play Nice

Posted by matijs 13/12/2009 at 18h58

The Problem

You have been running a Typo blog [since 2005][since], but you still can’t quite get your Apache configuration right. In particular, you still get the occasional

Not found: http://www.matijs.net/blog/2005/07.html/24/from-bryar-to-typo

Note the weird 07.html part.

The Solution

This particular message turns up if you have turned the MultiViews option on: The file 07.html was cached earlier, and Apache finds it a good candidate for the 07 part of the URL. Of course it can’t find a subdirectory 24 inside that file! I personally consider this behavior extremely weird, but that doesn’t make it go away.

The solution is to turn off MultiViews and implement a poor man’s version that does no more than what’s needed.

# Turn off MultiViews
<Directory /var/www/www.matijs.net/public>
    Options FollowSymLinks -MultiViews
</Directory>

# Rewriting must be on
RewriteEngine on

# Implement simplistic MultiViews in the blog sub-uri
RewriteCond %{QUERY_STRING} "^$"
RewriteRule ^/blog/?$ /blog/index.html [QSA,L]
RewriteCond %{QUERY_STRING} "^$"
RewriteRule ^/blog([^.]+)/?$ /blog$1.html [QSA,L]

# Implement simplistic MultiViews elsewhere (static content)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d
RewriteRule ^([^.]*)$ $1/index.html [QSA,L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.html -f
RewriteRule ^([^.]*)$ $1.html [QSA,L]

That ‘s it.

Some notes:

  1. The mapping to html files is implemented differently in the $/blog$ sub-uri than elsewhere. In the static part of the site, if there’s an URI /some/where, and and URI /some/where/else, this is stored on disk as /some/where/index.html and /some/where/else.html, respectively. In the blog part, Rails’ static caching system uses /some/where.html and /some/where/else.html.

  2. Turning on MultiViews for the static part of the site is not possible, since turning it off for the blog then does not seem to work. This may have something to do with the directory layout demanded by Passenger.

  3. It’s easy to get this wrong and cause Apache to never see the cached files. It’s also easy to get this wrong in other ways.

  4. The QSA part is probably not necessary. Call its presence a case of cargo-cult configuration.

  5. If your blog is not in the sub-URL blog you’ll have to change things, of course. Good luck.

Tags , , no comments no trackbacks

Hello New Year!

Posted by matijs 23/01/2008 at 06h36

It’s a new year! Time for more resolutions. I can’t believe that’s actually two years ago.

Yes, my blog has been neglected, but not for want of anything to write about. Oh, there are so many things I have an opinion about. But always, it’s the question, is my opinion interesting, new, well informed, etc? And can I write something sizable about it? Not conductive to writing every monday (recently replaced by sunday, but I bet you hadn’t guessed). Maybe I should try less hard to be reasonable.

Oh yeah, e-mail is getting better, mainly thanks to the Inbox Zero articles.

What I really want to be doing: I still don’t really know, but let’s look at what I might blog about:

  • Size is the Enemy, leading to the issue of abstractions in programming languages.
  • 80/20, or the problem of getting your average Java/.NET programmer to really learn and use new things (e.g., new methods of abstraction).
  • Lots of new languages are popping up, all running on some VM or other (e.g., Scala, Nemerle, Boo). Where’s the development in regular compiled languages?

This surely points in some direction, but some weighted average will have to be taken to find out what that direction is.

I did manage to quit the job that was definitely going in the wrong direction, so there’s a plus.

Oh, you wanted new resolutions? Hm, let’s do some:

  • Uncluttered house
  • Learn Japanese
  • Finish more software so it’s releaseable

Tags , , no comments no trackbacks

Outage

Posted by matijs 18/06/2007 at 13h13

Last week, I did some work on my website, upgrading to the latest Typo trunk and Rails 1.2, and changing from mod_fcgid to a Mongrel cluster.

Last Friday or so, I rebooted my server. Unfortunately, I had neglected to make the Mongrel cluster start at boot. So for the past weekend, all you have seen here is a Service Temporarily Unavailable message.

Sorry.

Tags no comments no trackbacks

Resistance to Posting

Posted by matijs 25/03/2007 at 13h05

Daring Fireball talks about about an interesting post by Tantek Cilek about Human Interface Design. It’s true that there is some cognitive load in posting a blog entry as opposed to just answering What are you doing?

Partially, that resistance is good. Like forums, or blog comments, the Twitter entries are mostly like noise. A soothing background hum that lets you know other people are alive and going about their business. Unfortunately, that business is often uninteresting in the long run. So how long are we willing to store it, even for ourselves?

On the other hand, it is annoying that I have to come up with a title that covers this little post that wanders all over the place. Or that so many thoughts end up as half-finished posts in my drafts pile.

Tags , no comments no trackbacks

Trackback Spam

Posted by matijs 22/10/2006 at 11h23

The less said about it the better. I just blocked three IP ranges completely. I don’t really like to take these kinds of measures, for two reasons:

  1. I don’t want to block legitimate access to my web site.
  2. I don’t want to spend my days adjusting my firewall, adding rules whenever new spam seeps through the cracks.

Since I was spending my days cleaning up trackback spam, reason #2 stopped applying. There also didn’t seem to be any legitimate access from the blocks in question.

Damn Spam has more details on these particular spammers. You can see they’ve been at it for a while now.

Before, I only blocked one IP address. It was from a company called Webrescuer with a very impolite bot. Aparrently, being impolite wasn’t a very good business model, as they seem to be gone now. I removed the block.

Tags no comments

RSS Sucks, Atom Rules

Posted by matijs 26/03/2006 at 14h37

Why we need Atom now
by Tim Bray (via
bitworking)
once again brought the horrors of RSS to the front of my
working memory. I will not elaborate here, but the main problem seems to be
that there are nine versions of RSS, and even
more implementations. The result is that you can never get things right.
Atom to the rescue.

Not wanting to be the
Bitch and Moan But Never Does type,
I removed all links to RSS feeds from my web site. The remaining links are
all Atom feeds, but the word Atom will not be in the link text, to
facilitate the fading of technical details into the background.
It’ll just say feed.
I will probably add the new standard feed icon.

The RSS feeds are still there, of course, since
I want my URIs to be permanent.

Tags , no comments no trackbacks

Customizing Typo

Posted by matijs 27/08/2005 at 18h13

For many reasons, I like to customize the typo program code a little. Much, but not all is customizable by using themes.

I keep my version in a local repository, and I’ve just updated to typo 2.5.5. Here is the way to do these updates, partly so I can remember it myself.

Tags no comments no trackbacks

From Bryar to Typo

Posted by matijs 24/07/2005 at 18h26

As of yesterday, my blog runs on Typo. All in all, I have been quite satisfied with Bryar, but it was time for a change.

I like Bryar because it is simple (no frills, entries are stored as files), and yet easy to customize (to change the layout there's basically one template to update). In addition, it is written in Perl, a language that I like, and that I'm fluent in, so getting it to work the way I wanted was easy. So, I'm happy that I chose it a year ago.

A combination of events lead me to change over to Typo.

Tags no comments no trackbacks

Blafoolia!, for want of a better title.

Posted by matijs 24/01/2005 at 19h59

People who visit this site more often than once may have noticed that I changed its layout. It took a lot longer than I expected: It's easy to just whip something up that looks nice, but it's much harder to take a thought sketched on a piece of paper and make that happen in CSS. It's harder still if you want to make it work in old browsers.

In addition to the change of layout, I did a redesign of the URLs my site serves.

A new design

The result is much as I originally imagined it: a paper border with navigation links, floating above a paper background with the main text. However, the paper was supposed to be darkish, with a glow coming from underneath the border illuminating the lower sheet.

Based on Simon Cozens' version of the rounded border layout, I first produced a nice resizing border layout. Unfortunately, it only works with browsers that support :before and :after pseudo-elements. Also, I still had to add the paper look, and I really wanted a two-column layout.

I took a stroll around the css Zen Garden for some inspiration, and found most designs use a fixed-width layout to underlay their columns with an image that provides the borders and decoration (The design called Verdure is an example). So, I decided not to worry about possible 300dpi display technologies of the future, and use a fixed pixel width too.

After some initial fumbling with floats I decided I needed to actually know how they worked instead of doing cargo-cult CSS design. The autistic cuckoo was helpful enough to explain both floats and the different kinds of positioning very clearly.

Possibly the last time I'll do IE hacks

Since I had given up on my Amazing Resizing Frame anyway, I decided that I should make the design look as intended in Internet Explorer as well. After all, about half of you, dear readers, still seem to be using that piece of crap. So, I had to find out:

  • What my site looked like in different flavors of IE, and
  • How to make it look the way I wanted it to look.

Now I don't have IE running at all, so I had to bug Thomer to send me screen shots from IE 6, and send more screen shots whenever I changed something (I tried using ieCapture, but it seems to be permanently overloaded). Then, I had to bug someone at work who has IE 5.5 running to see what that looked like.

To actually get things to look properly, I made great use of How to hide CSS from browsers, and Position is Everything, a great repository of browser quirks.

Truly permanent links

While checking the validity of my HTML, I came across a tip from W3C about choosing URIs. Now, I don't even want to understand the difference between URIs, URNs and URLs, but it was still very useful. So, now all (user-visible) URIs are truly permanent, and as a bonus, they don't have file type extensions anymore (the ones with extensions are properly redirected), so I can safely serve up my ancient blog archives in the file-format-du-jour when I'm 205 (I mean, it's not like the cure for aging isn't just around the corner).

And when I do really remove stuff, I promise I'll pronounce it gone.

Other notes

To create my background, I took a picture of some nice-looking paper and processed that with the GIMP. Jeffrey Zeldman showed me that it's possible to create a convincing floating paper effect using simple shadows.

Virtuelvis explains rounded corners too. Very nice for putting things in a box. Very much needs a standards-compliant browser.

Blafoolia is a word I made up that Google doesn't know.

Tags no comments no trackbacks

CSS Shame

Posted by matijs 25/11/2004 at 23h42

All this time, it turns out, people using IE5.5 (36 so far this month), and perhaps IE5.0 (44 so far this month), have been unable to read my website: The left and right sides of the text were simply cut off. I knew IE6 didn't show the vertical borders, but at least it showed the whole text.

Somehow, it feels similar to suddenly finding out you've been walking around all day with mismatched socks, or a torn shirt — assuming those things weren't part of your fashion statement. It's simply a little embarrassing. Anyway, it should all look fine now. The vertical borders even show up in IE6.

Oh, and I'm working on a new layout, so here are samples before and after, just in case the site looks completely different when you read this.

Tags , 1 comment no trackbacks