Archive

Monthly Archives: August 2010

At work we use ExtJS (now known as www.sencha.com), a Javascript library for building interfaces. ExtJS does some browser detection during its initialisation and adds classes to the HTML body tag:

Safari:

<body class="ext-webkit ext-safari ext-safari4">

Firefox:

<body class="ext-gecko ext-gecko3">

IE7:

<body class="ext-ie ext-ie7">

and so on.

You can use these in your CSS to cleanly apply browser-specific CSS, e.g.

.ext-ie div.dashboard-menu1 {
     padding-right: 1em; /* prevents italics being clipped in IE */
}

Simple but effective. Even if you’re not using ExtJS, you could easily roll your own version of this technique using whatever browser detection library you use.

A customer reported a bug with an AJAX-powered web UI. The problem only manifested itself at certain times of day, coinciding with high traffic to the web server, indicating that it was load-related.

So, how to simulate a sluggish server to try to reproduce the problem?

Apache itself doesn’t seem to provide any throttling. There are third-party modules out there to do it but I didn’t want to spend the day compiling Apache.

I found this simple command line UNIX tool which limits i/o:

http://klicman.org/throttle

It built cleanly from source and worked as advertised.

To stick this between the browser and Apache, I used the mod_ext_filter Apache module (http://httpd.apache.org/docs/2.2/mod/mod_ext_filter.html) which lets you filter Apache’s output through an external command. It’s a built-in module and seems to be enabled by default in my stock Apache (on Fedora Linux).

To simulate a good ol’ 56kbps modem, the httpd.conf magic is:

    ExtFilterDefine throttle
        mode=output
        cmd=”/local/tmp/throttle-1.2/bin/throttle -k 56″
        preservescontentlength

    <Location />
        SetOutputFilter throttle
    </Location>

 

%d bloggers like this: