Thursday, January 24, 2008

Serving Gzipped content - Test for browser-support

In the newest version of the CMS I'm working on/maintaining, a couple of customers got strange errors. The culprit was that for some reason or other, their browser didn't accept gzipped content.

The workaround


acceptsGzip := ( @Contains( @GetHTTPHeader( "Accept-Encoding" ) ; "gzip" ) );

{<script src="/} + @WebDbName +
@If( acceptsGzip ; "/gz/mootools.js" ; "/lib/mootools.js" ) + {"></script>}

1 comments:

Leus said...

Hi,

We recenty had some problems with serving gzipped content to users using Internet Explorer 6. Altough IE6 says it supports gzip, it (sometimes) doesn't decode it correctly. Seems to be a bug/ feature: search Google and you'll find lots of users with the same problems.

That's why we've also included a IE6 check. Use the non-gzipped version if:

(@LowerCase(@BrowserInfo("BrowserType"))="microsoft") & (@BrowserInfo("Version")=6)

Mark