views:

112

answers:

1

I can't seem to find an answer to this anywhere. It's well known that certain versions of IE6 and earlier incorrectly declare they accept gzip encoding. Does ob_gzhandler correctly detect these versions or do you need to do that separately?

+2  A: 

No, it doesn't; you have to, like so:

<?
function checkIEFail() {
    $ua = $_SERVER['HTTP_USER_AGENT'];
    if(strpos($ua, 'Mozilla/4.0 (compatible; MSIE ') !== 0 || strpos($ua, 'Opera') !== false)
        return false;
    $version = floatval(substr($ua, 30));
    return $version < 6 || ($version == 6 && strpos($ua, 'SV1') === false);
}

if(!checkIEFail())
    ob_start('ob_gzhandler');
?>
chaos
The use of `!== 0` and `!== false` confused me for a few minutes! This isn't the most readable code, but I'm pretty sure it works. Any idea what percentage of browsers will match this test? Is it low enough to no longer support it I wonder?
Liam
IE6 still has 7.1% market share, which is *a lot* of people if you're doing srs bzns, maybe ignorable otherwise. No idea how much of that does and doesn't have SV1 though.
chaos