minify-kohana
minify-kohana copied to clipboard
File corrupted while using gzip encode method
Hi there, I have a trouble with gzip encoding.
When I set
'encodeMethod' => '',
everything works just fine.
But when I set
'encodeMethod' => NULL, // automatic encoding
the compressed file is corrupted.
This behaviour is not only my local dev-server, but also on the production server, so I beleive this is not happening thanks to my dev-server settings.
After downloading the file via the browser while encoding is set to NULL, the incomming file is corrupted at the end and it final size (after downloading and saving on the disc) is lower then the file without encoding.
Here are the headers:
encoded:

not encoded:

The older PHP version is not the reason. I have 5.6.14 on my production server and the issue is the same there.
I also wanted to attach both CSS versions as an example, but GitHub has not managed to upload my TXT files with uknown reason (it says "Something went really wrong, and we can’t process that file."). Even the MS Word version has not helped.
My Kohana version is 3.3.3.1.
Is there any chance you could help me with this issue?
Thanks, Pert
hello, can you please verify if it's any of those issues at fault?
https://github.com/mrclay/minify/issues?q=is%3Aissue+encodeMethod+is%3Aclosed
No, I don't think so. I believe this is another issue.
P.S.: At this time I use your recomended version of minify vendor: https://github.com/mrclay/minify/tree/db7fe244932ea77cf1438965693672ea12b33da8
I guess it deserves an upgrade then, since version 2.2 was released last year.
OK, I haven't known it is possible :-)
Your solution was ready to use. I could only download the sources and run.
With the latest version of minfy it needs to set up the project dependencies = to have some shell, composer etc. This is not so clear for me a s Windows user :-)
Is there any chance a quick help how to upgrade the Minify in my case?
Thanks.
I managed to install the dependencies ;-) But the latest minify version is not compatible with this version of minify-kohana, so I am stuck.
yeah, I'll upgrade the dependency and fix the code, since I use this module everywhere in my Kohana projects as well
Great news, thank you!
Hi there. Any news? :-) Have you managed to updated the dependency? Thank you for your reply.
See if the code in the master branch works for you.
It's unfortunately still the same. When I open /min/css the browser says the file is not valid or using unsupported compression method.
ok, so maybe the problem is a double compression. make sure that PHP and Apache isn't gzipping the output at the same time
Thank you. I found out it's a Kohana problem. When I serve the static HTML file or PHP file without Kohana, gzip works fine. But the ouput made by Kohana is not "gziped". Unfortunately I have no idea why. Anyway... it is not Minify issue. Thanks.
Update: When I use the Kohana without Minify module (remove it from the bootstrap), the gzip works fine. Strange :-)
can you show me your application/config/minify.php? If you are using Apache, does adding this to the .htaccess helps?
<IfModule mod_env.c>
# In case AddOutputFilterByType has been added
SetEnv no-gzip
</IfModule>
you can also see if changing the setting to makes anything difference:
return [
'serveOptions' => [
'minifierOptions' => [
'text/css' => [ 'compress' => false ],
]
]
]
Here it is:
return array(
'serveOptions' => array(
'encodeMethod' => '',
),
'groupsConfig' => array(
'js' => array(
'//resyst/assets/js/resyst-frontend.js',
'//resyst/assets/js/resyst-popup.js',
'//assets/js/js.min.js',
),
'css' => array(
'//assets/css/screen.css',
'//resyst/assets/css/resyst-popup.css',
),
),
);
It is also strange that after this module is loaded, all files (including HTML served by Kohana) are without any compression.
When I set the "encodeMethod" to NULL (automatic), the assets are not working as I wrote before.
If I "hack" the module and delete the
ini_set('zlib.output_compression', '0');
in your init.php file, the assets (and compression) are working, but it takes about 10 seconds to render the site (and 9 seconds the browser is waiting on the assest). Without Minify the site is rendered about 0,5 s
usually the initial cache takes a lot of time, and subsequent requests work faster. is it the case?
it's weird that removing a setting that disables zlib compression would make it work, because the code is manually gzipped inside minify. maybe new versions of PHP changed something that I'm unaware of
Would be interesting to watch for 'hidden' compressions toggles in php_info(); output as well
It is slow for every reload of the page. Maybe it is some webhosting issue...