Skip to content

Instantly share code, notes, and snippets.

@nicolas-grekas
Created September 10, 2012 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolas-grekas/3690108 to your computer and use it in GitHub Desktop.
Save nicolas-grekas/3690108 to your computer and use it in GitHub Desktop.
Test if browser supports compression
<?php
if (isset($_GET['i']))
{
// Send a blank gzipped GIF to test browser capability to decode it
// See http://www.stevesouders.com/blog/2010/07/12/velocity-forcing-gzip-compression/
header('Content-Type: image/gif');
header('Content-Encoding: deflate');
header('Pragma: no-cache');
header('Expires: Fri, 01 Jan 2000 00:00:00 GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Content-Length: 39');
echo base64_decode('c/d0s7BMZGRgZGhgYPj//z8DA4PiTxZGIMWgAyJAMgxMTC6MDNYA');
}
else
{
?>
<script>
a = new Image;
a.onload = function(){alert(‘OK’);};
a.onerror = function(){alert(‘KO’);};
a.src = "<?php echo $_SERVER['REQUEST_URI'] . "?&i=1"; ?>"
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment