Having problems with gzip - php

I have some problems with gzip encoding and I just can't figure them out!
I added in my htaccess "AddOutputFilterByType DEFLATE ... ..." and I used the tool from http://www.gidnetwork.com/tools/gzip-test.php to check if my pages are encoded properly. The tool says everything is ok.
The problem is that when I check the pages with the web developer tools from chrome or firebug, they don't recognize the pages as gzipped. In the headers section the "content-encoding: gzip" does not appear and PageSpeed also says they are not encoded and recommends me to encode them.
Any ideas? Thanks.
Adi Ulici

AddOutputFilterByType is deprecated try AddOutputFilter instead, eg
AddOutputFilter DEFLATE php js css html

Related

mod_deflate is not working for php generated page

mod_deflate not working for php generated page. I have Apache v2.4.7 with php v5.5.9 on Ubuntu 14.04.5 (LTS). This module is working for static html pages and other files like CSS, js etc.
here is my php information http://www.hostnology.com/test.php
Only content is deflated, if you use HEAD http verb, there is no content, so no need to deflate it
You can set (or there is) parameter in httpd that activate deflate on some mime type. (no need to deflate jpeg for instance)
if content type is small (like <1k) there no point to deflate (size almost same)

Can't resolve Google pagespeed "Enable compression" point using Yii2

Site in question is http://burghleys.com/
Having trouble trying to improve the Google pagespeed score and says I need to enable compression with a 70% improvement on the JS file for example but I can't make the same improvement at all!
https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fburghleys.com%2F
I have GZIP enabled and use the apache mod_deflate to do so, tested as per http://checkgzipcompression.com/?url=http%3A%2F%2Fburghleys.com%2F
I use yii2 https://github.com/rmrevin/yii2-minify-view plugin to compress my files which generally works really well.
I use the HTML5 boiler plate htaccess file.
I tried manually compressing the JS file but can only reach 25%. CSS is even less yet states i can save 80%.
Any thoughts?
ps. I'm working on the other issues too, wanna get that 99 score.
You do have GZIP enabled for some items but if you follow the link to your js you will see that this resource is not being zipped up.
http://checkgzipcompression.com/?url=http%3A%2F%2Fburghleys.com%2Fminify%2Fb329b2d2ce53b5c6be05decfe5e5d723527a666e.js
Add the following line to your .htaccess
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/xml application/xhtml+xml application/rss+xml application/javascript appliction/x-javascript

Confusion about gzip, is it compressed or not?

Sorry to bother you with a question that seems very well documented, but none of the things I tried was completely satisfying.
My Company switched from a hosting package to a manages Server just last week and I'm still in the process of optimising it.
Now, Googles PageSpeed Insights tell me, it is not compressed, as does GTMetrix. GidNetwork tells me compression works fine.
I have already added
<IfModule mod_deflate.c>
<FilesMatch "\.(html|php|txt|xml|js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
to my .htaccess, (as recommended here) which works correctly, other settings I've changed are fine, as well as
zlib.output_compression = On
to my php.ini.
The entire .htaccess and php.ini can be seen at jsFiddle.
Headers sent and received in both Firefox and Chrome claim that compression is happening.
I also created a httpd.conf in my home directory, because none existed on my server yet. Should I move the file somewhere else?
What I really want to know:
Soo... what am I doing wrong? Is it compressed? Is it not? How can I make google 'see' the compression?
Thank you very much for your help.
This should be the function you need, it should automatically generates the headers you need:
http://www.php.net/manual/en/function.gzdecode.php
anyway check your php version because it works only with php 5.4.0 or later ones.
Although my browser accepts deflate/gzip encoding (Accept-Encoding: gzip, deflate), your server does not answer using compressed data:
HTTP/1.1 200 OK
Date: Tue, 11 Mar 2014 09:41:45 GMT
Server: Apache
Connection: Keep-Alive
Keep-Alive: timeout=2, max=200
Etag: "96-100e9-4f4517d791912"
Expires: Fri, 11 Apr 2014 13:28:25 GMT
Cache-Control: max-age=2692000, public
Vary: User-Agent
If it was compressed, the server would send also
Content-Encoding: deflate
Use FireBug or the dev console to see the headers. It must be your httpd.conf.
You cannot simply create this file in your home directory and Apache will load it.
Have a look in /etc/apache* and /etc/httpd/* for config files.
You have already enabled gzip compression but you haven't set it to compress some file types such as javascript and css. That is why Googles PageSpeed was tried to suggest to enable compression. To enble compression for those two types, use
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
What worked for me in the end to compress the js/css files that were left uncompressed for reasons I don't quite get yet is described here.
In this method, javascript and css-files are forcibly gzipped by a php-script. It also sets new "Expire"-Headers, so if you want caching for more than 5 Minutes, change the number. Adding different files is trickier, but possible, I think.

php-created rss feed has encoding errors since on new server

After moving a website from one webserver (Apache 1.3) to another (Apache 2.0 at domainfactory), the W3C feed validator says the feed is correct but has two problems:
Feeds should not be served with the "text/plain" media type
Your feed appears to be encoded as "ISO-8859-1", but your server is reporting "US-ASCII"
php-created rss feed
The help link didn't help.
Firefox and Chrome show the source code instead of the nice feed view (other feeds are shown correctly).
We are using php 5.3.6 to generate the feed: http://www.stuttmann-karikaturen.de/feed.rss. It's generated as a file, not on-the-fly.
We have tried adding (alternatively) the following lines to .htaccess:
AddType application/rss+xml .xml
AddType application/xml .xml
AddType text/xml;charset=iso-8859-1 .xml
No change. Any ideas?
Kwebbles answer did it for me. In case someone has a similar problem, here's the correct AddType line that worked:
AddType text/xml;charset=iso-8859-1 rss
If the extension of the resource is .rss I think the AddType directives should also use that.
Don't use .htaccess, use a PHP header to make those settings.

Why is gzip compression with Internet Explorer not working?

My site is gzipped compressed, and it doesn't load properly in IE. It works fine in FF/Chrome, but in IE, the only thing that pops up is a box asking to download the .gz file which contains the html document for the page.
Is this normal? Do I have to turn off gzip?
Are you sending the correct headers?
You need to send the
Content-Encoding: gzip
header for IE to understand that it is gzipped (Firefox, et al are smart enough to detect this automatically - even though they shouldn't!)
In PHP, you can do this using:-
header('Content-Encoding: gzip');
One thing to add - you should turn off gzip compression for IE6 pre-SP2. Before SP2, IE6 doesn't always read and cache gzipped content properly and you end up with mangled code.
You can identify an IE6 SP2 install by looking for "SV1" in the user-agent string.
I have seen problems when using gzip with Internet Explorer on a page that has flash on it. If your page has flash this may be why. I don't remember the cause and at the time we found it it was causing problems on a live site so we just disabled gzip for Internet Explorer to get around it.
The HTTP headers are the issue. If you have the gzip header along with one of the following:
Vary
Transfer Encoding: Chunked
one or both need to be removed.
This problem is more likely to occur on a computer that is running Apache HTTP Server because Apache HTTP Server can use chunked encoding on any kind of file. This includes static files such as a JavaScript file or a .gif file. When the problem that is described in this article occurs, the content that is stored in the Internet Explorer cache may be truncated or corrupted.
For XML, XHTML, and XSLT files, prevent parsing as text/html or text/xsl:
RewriteCond %{HTTP_ACCEPT} text\/html [OR]
RewriteCond %{HTTP_ACCEPT} text\/xsl [OR]
RewriteCond %{HTTP_ACCEPT} gif|jpeg|png$
ReWriteRule .*\.(xsl|xslt)$ - [F]
And add application/xml as a content type mapping:
AddType application/xml .xsl
References
Internet Explorer may not decompress HTTP content when you visit a Web site
Vary with Care
IE 8 seems unable to display some Wikipedia Pages - application/x-gzip-compressed MIME type
Internet Explorer 6 does not display XHTML strict Web pages correctly

Categories