-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
"Content-Encoding: none" breaks mod_deflate #548
Comments
I agree, will fix. |
Actually that Basically the whole fix was Please do not remove the line; it just breaks the code. |
PHP does not have a way to close STDOUT. If you have something to process after the page has been sent, browser (and mod_deflate) will keep expecting more data and user needs to wait until PHP stops running before the page has been fully loaded. The only way to work around this is to send Content-Length and make client to close the connection when it has received all the data (except if you are using FastCGI, which has command to close the connection). Assuming that you aren't using FastCGI, mod_deflate will never get the information that all the data has been sent and it will continue to expect more data regardless what you try to do. So the only way is not to use mod_deflate in this case. All of this said:
In the second case request should probably not send |
New logic should allow Without FastCGI there is not much that can be done because of the limitations of PHP. In this case you are better off using Grav's implementation of gzip. |
Hi, thanks for your feedback. is fwiw, I'm using php-fpm. It might be possible workaround it using |
We replied at the same time. Please see my comment from above. |
To reply to your questions, I fixed the code to close the connection properly for you (php-fpm).
If you have ideas on how to do this in a better way, I'm all ears. At least the issue doesn't exist anymore with FastCGI. :) |
great, thanks a lot 👍 |
Hello, This trick, seems to break on LiteSpeed when gzip is disabled in grav. Litespeed manages it's own gzip compression using a gzip cache which is much more efficient than what PHP can do) and add's gzip to the headers if it doesn't exist resulting in : Content-Encoding:none,gzip The result of this is that the browser show's the Gzip compressed content instead of compressing it. If we comment out Content-Encoding:none the page loads without any delay on litespeed, I've also asked them if they have an equivilent to fastcgi_finish_request(). Some of your featured hosts also use litespeed, so I guess they also have to deal with this issue too. |
Unless they have similar function to The main reason for the code we have is that it allows us to close the connection and to continue processing some cron job taking a lot time. Without the ability to close the connection, users would see page loading a long time even if they already received the whole page. |
LiteSpeed can compress response with content-length header set without any problem. A properly written web server should be able handle it. When LiteSpeed compress the response body, it replaces "Content-Length" header with "Transfer-Encoding: chunked", the compressed response wont cause browser to spin forever. Looks like we need to drop the "Content-Encoding:none" header internally. |
I just found this issue because I was having a problem validating my site. The W3C Markup Validation Service will not work with a "Content-Encoding: none" header. It stops with an error "Don't know how to decode Content-Encoding 'none'". Changing the value for system.cache.gzip to true in user/config/system.yaml fixed that. |
@rhukster I think the correct one would be using |
What is the state of this issue? I have run on it as @ulab and his solution works fine, but that means the default behaviour is buggy? |
Try latest CI build of Grav if it works in there. |
Ok, so i've made a change to this. Changing to 'identity' was causing some encoding problems for some people. I've rolled back the default to 'none' which actually works more reliably with our |
@rhukster, you may want to comment this behaviour in the docs. The impression I got when tried to validate my site with W3C validator is that there is something broken. Gzip is recommended, but now should be considered a must if you want your site to be correctly validated and/or perhaps indexed (if W3C refuses to read the content, there is no warranty others will do). |
I have a note in my "items to document" mega issue: getgrav/grav-learn#356 You can enable Gzip via the grav option directly. This will ensure gzip is working for the .php pages, and it will still work with onShutdown() event properly. |
Hi,
I'm using
mod_deflate
instead of grav's builtin gzip-compression because it's more flexible for my needs.As grav sets the header
Content-Encoding: none
insystem/src/Grav/Common/Grav.php
when havingsystem.cache.gzip
set tofalse
, grav is preventing httpd from compressing the output. Imho there's no need for setting this header when compression is not wanted.Kind regards,
Phil
The text was updated successfully, but these errors were encountered: