Toxic Elephant

How to Get Apache and Typo Page Caching to Play Nice

Posted by matijs Sun, 13 Dec 2009 18:58:00 GMT

The Problem

You have been running a Typo blog since 2005, 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.

Posted in , ,  | Tags ,  | no comments | no trackbacks

How to compile TV output into the latest X.org ati drivers on Ubuntu

Posted by matijs Thu, 21 Jun 2007 12:58:00 GMT

The Problem

You have built a home server slash PVR that you want to hook up to your twenty-year-old television. You have gone to several shops to buy a graphics card that actually has open-source drivers for its TV output functionality (i.e., the ATI Radeon A9250). You have dodged salesmen trying to sell you something else (“No, but here is its successor the NVidia so-and-so.” “Uhm, no thanks.”). You finally succeeded by ordering it over the Interweb (and probably should have done that in the first place). Now you want to patch the driver shipped by Ubuntu to actually get TV output working.

Read more...

Posted in ,  | Tags , , , , ,  | 11 comments | no trackbacks

How to Trim Spaces in TeX

Posted by matijs Thu, 20 Jul 2006 19:27:00 GMT

The problem

You created a macro package for LaTeX and promised that people could write either

\synttree[ a label ]

or

\synttree[a label]

and the result would be the same. Now your buggy macro for trimming spaces stands in the way of a much needed bug fix.

In short, you need a macro \trim that will trim (The name says it all, doesn’t it?) spaces off of its argument’s beginning and end.

Read more...

Posted in ,  | no comments | no trackbacks

Toxic Elephant is Matijs van Zuijlen's weblog.

Powered

Categories

Archives