Created
September 10, 2012 10:11
-
-
Save nicolas-grekas/3690108 to your computer and use it in GitHub Desktop.
Test if browser supports compression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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