Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File corrupted while using gzip encode method #8

Open
petr-g opened this issue Oct 7, 2015 · 18 comments
Open

File corrupted while using gzip encode method #8

petr-g opened this issue Oct 7, 2015 · 18 comments

Comments

@petr-g
Copy link

petr-g commented Oct 7, 2015

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:
headers not ok

not encoded:
headers ok

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

@pocesar
Copy link
Owner

pocesar commented Oct 7, 2015

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

@petr-g
Copy link
Author

petr-g commented Oct 7, 2015

No, I don't think so. I believe this is another issue.

@petr-g
Copy link
Author

petr-g commented Oct 7, 2015

P.S.: At this time I use your recomended version of minify vendor: https://github.com/mrclay/minify/tree/db7fe244932ea77cf1438965693672ea12b33da8

@pocesar
Copy link
Owner

pocesar commented Oct 8, 2015

I guess it deserves an upgrade then, since version 2.2 was released last year.

@petr-g
Copy link
Author

petr-g commented Oct 8, 2015

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.

@petr-g
Copy link
Author

petr-g commented Oct 8, 2015

I managed to install the dependencies ;-)
But the latest minify version is not compatible with this version of minify-kohana, so I am stuck.

@pocesar
Copy link
Owner

pocesar commented Oct 9, 2015

yeah, I'll upgrade the dependency and fix the code, since I use this module everywhere in my Kohana projects as well

@petr-g
Copy link
Author

petr-g commented Oct 9, 2015

Great news, thank you!

@html-koder-com
Copy link

Hi there. Any news? :-) Have you managed to updated the dependency? Thank you for your reply.

@pocesar
Copy link
Owner

pocesar commented Mar 2, 2016

See if the code in the master branch works for you.

@html-koder-com
Copy link

It's unfortunately still the same. When I open /min/css the browser says the file is not valid or using unsupported compression method.

@pocesar
Copy link
Owner

pocesar commented Mar 3, 2016

ok, so maybe the problem is a double compression. make sure that PHP and Apache isn't gzipping the output at the same time

@html-koder-com
Copy link

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.

@html-koder-com
Copy link

Update: When I use the Kohana without Minify module (remove it from the bootstrap), the gzip works fine. Strange :-)

@pocesar
Copy link
Owner

pocesar commented Mar 3, 2016

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 ],
       ]
   ]
]

@html-koder-com
Copy link

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

@pocesar
Copy link
Owner

pocesar commented Mar 3, 2016

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

@html-koder-com
Copy link

It is slow for every reload of the page. Maybe it is some webhosting issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants