I wasn’t able to attend Velocity this year but have been consuming what I can find online and this article from a few days ago from Steve Souders talks about a great approach to handling clients (or more likely proxies and software) that don’t claim to handle Gzip content.
From Andy Martone’s presentation:
- At the bottom of a page, inject JavaScript to:
- Check for a cookie.
- If absent, set a session cookie saying “compression NOT ok”.
- Write out an iframe element to the page.
- The browser then makes a request for the iframe contents.
- The server responds with an HTML document that is always compressed.
- If the browser understands the compressed response, it executes the inlined JavaScript and sets the session cookie to “compression ok”.
- On subsequent requests, if the server sees the “compression ok” cookie it can send compressed responses.
The iframe test only runs once so the impact to performance is minimal (and to start the sample size of those getting the test is a small fraction of your traffic). The upside is that you quickly gain a savings by delivering Gzip payloads to any client that can handle them. From their testing you might improve the experience for ~15% of your users.
Of course there are still those using seriously old browsers and just can’t handle the compression, but I would say that burdening them with an extra iframe might give them that final reason to upgrade.
via High Performance Web Sites :: Velocity: Forcing Gzip Compression.