php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53627 ob_gzhandler don't gzip some JS file
Submitted: 2010-12-29 11:59 UTC Modified: 2010-12-29 17:02 UTC
From: dmaillefer at gmail dot com Assigned:
Status: Closed Package: Output Control
PHP Version: 5.3.4 OS: windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
8 - 6 = ?
Subscribe to this entry?

 
 [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 ?


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 17:02 UTC] dmaillefer at gmail dot com
-Status: Open +Status: Closed
 [2010-12-29 17:02 UTC] dmaillefer at gmail dot com
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 !!!!!!!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 23:01:29 2024 UTC