| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2010-12-29 11:59 UTC] dmaillefer at gmail dot com
 Description:
------------
hello
when I try to create compression function on CSS and JS file I found a strange 
issue
all my css file and JS file is correctly Gziped but not JQuery.js (minimized or 
not) 
I try with a regulard PHP code (ob_start('ob_gzhandler') ) 
or directly in the php.ini (zlib.output_compression = On)  
the result is the same the Jquery JS will not be compressed 
If I delete some line in the file compression is done (but the file is 
incomplet)
If I add other file (to the JQuery JS) who are correctly compressed the all file 
are not compressed
If I configure in Apache the mod_deflate all file are Gziped 
The JQuery file are here http://jquery.com/
I look if the compression is done with chrome (developement tools)
Here when the compression is done with PHP 
http://img709.imageshack.us/f/screenshot220t.jpg/
Here where the compression is done with Apache 
http://img52.imageshack.us/f/screenshot221q.jpg/
In the HTTP header response the GZIP is correctly set
the file I use is here http://www.megaupload.com/?d=AVY3LFQO
best regards
Test script:
---------------
<?php
// to activate to compress with PHP
/*
if(extension_loaded('zlib')){
    ob_start('ob_gzhandler');
}*/
header("Content-type: application/javascript");
header ('cache-control: must-revalidate');
$offset = 60 * 60 * 24;
$expire = 'expires: ' . gmdate ('D, d M Y H:i:s', time() + $offset) . ' GMT';
header ($expire);
// test with include
// liste JS files to be included
//include 'jquery-1.4.4.min.js';
//include 'sha256.min.js';
// test with join file
echo join('',file('sha256.min.js')); // works
echo join('',file('test.js')); // works
echo join('',file('style.css'));  // works
echo join('',file('jquery-1.4.4.min.js')); // never works
// test with file get content
//$file = file_get_contents('jquery-1.4.4.min.js');
//echo $file;
// to activate to compress with PHP
/*if(extension_loaded('zlib')){ob_end_flush();}*/
?>
Expected result:
----------------
I just want to andersted what's happen, and why the compression fail with this JS 
file ?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 11:00:01 2025 UTC | 
hello I gzip the JS file directy in my folder and then I do $s = file_get_contents('mootools.js.gz'); header("Content-Encoding: gzip"); echo $s; chrome show me the javascript if I delete header("Content-Encoding: gzip"); I get unreadable caractere. But in chrome no information concerning the compression !!!!!!!