I have this code example to compromise my website with deflate:
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/json
</ifModule>
but I read on my provider site that I have also to insert this rule:
1-**mod_gzip_on Yes ?**is this rule is must or do I have to ignoer it?the code above is sufficient.
my second question is: I read this advise below !!
Some popular browsers cannot handle compression of all content so you may want to set the gzip-only-text/html note to 1 to only allow html files to be compresse. If you set this to anything but 1 it will be ignored.
what I understand that some browsers they don't support compromise, should I insert also the rules below here:
**BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/ht**ml
or just ignore it?
I don't understand your first question but if it's about using mod_deflate over mod_gzip then the answer is to use mod_deflate. Development stopped on mod_gzip years ago and mod_deflate is part of standard Apache and also (despite its name) uses gzip - though can also use the less widely supported deflate option if you want to but that is not recommended.
As to your second question that is no longer necessary either. Some very, very, very old browsers had bugs in them for gzip but now all browsers handle it well and tell Apache if they don't. None of those older browsers are in use anymore and even if they were they probably couldn't open your site for other reasons. See here for gzip browser support: http://schroepl.net/projekte/mod_gzip/browser.htm
How can you use Windows.Web.Http.HttpClient with gzip?
Currently focusing on Windows 10 application.
It just works.
Just make sure the request contains the following header:
Accept-Encoding: gzip, deflate
And I think it does by default.
You can disable GZIP decompression by creating a HttpBaseProtocolFilter with AutomaticDecompression set to false.
I'm trying to gzip my site. But I'm not sure if it's actually working..
When I'm checking at checkgzipcompression.com, WhatsMyIP.org and YSlow - they all tell me that the site is not compressed. Yslow also tells me that I have a couple of files that is not compressed, and of course suggest I do so.
This is the part, in my htaccess-file, that should compress the site:
<IfModule mod_deflate.c>
# Force compression for mangled headers.
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# Compress all output labeled with one of the following MIME-types
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/x-web-app-manifest+json \
application/x-httpd-php \
application/x-httpd-fastphp \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
</IfModule>
This code is based on h5bp (https://github.com/h5bp/html5-boilerplate/blob/v4.3.0/doc/TOC.md).
If I add ini_set("zlib.output_compression", 4096); to the PHP initiation script - both checkgzipcompression.com and WhatsMyIP.org tells me that my site is compressed. Along with the page weight in kb.
But YSlow still tells me that I have multiple files that is not compressed.
And in developer tools for both chrome and firefox shows the uncompressed filesize for each request/file (I'm not sure if that's how it suppose to be though(?)).
It does say Accept-Encoding: gzip,deflate, and Vary: Accept-Encoding, but nothing like Content-Encoding: gzip.
I just had a chat with my server provider -- BlueHost -- and they said that mod_deflate runs automatically on all of their servers. But since it's dynamic, most website scanners don't see it.
The conclution was that it's not possible for me to actually be sure that my site is in fact compressed.
The .htaccess-file is as it's shown above, and zlib.output_compression() is turned off - in case you have the ability to check it out..
The domain is: http://barkeeper.thomaskile.me
Here's a acreenprint of what firefox has to say about the page:
Same issue with Bluehost. I checked the actual file sizes and they are not compressed. Got the same BS that it automatic. First they tried telling me it only worked when the server was under a heavy load... apparently that person was clueless. Then I was told the server load threshold was low, and that compression was disabled when that threshold was exceeded. I am quite upset with these answers being all over the place.
I know this question has been asked several times on stackoverflow, but I couldn't find anything that worked for me in those questions.
I have a website hosted by BlueHost, and I am trying to enable gzip compression.
Here is (the relevant part of) my .htaccess file:
#GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript application/x-javascript text/plain text/html text/css text/x-component text/xml application/json application/xml alpplication/xhtml+xml
</ifmodule>
This code was given to me by BlueHost.
If I run Google's PageSpeed Insights, it recognizes the compression. However, when I run GTMetrix (which does PageSpeed and YSlow), neither of them recognize the gzip'd content. Also, I checked on http://www.gidnetwork.com/tools/gzip-test.php and I am serving gzip'd content.
Did I do something wrong, or does GTMetrix have a bug?
Google PageSpeed says I should "Specify a Vary: Accept-Encoding header" for JS and CSS. How do I do this in .htaccess?
I guess it's meant that you enable gzip compression for your css and js files, because that will enable the client to receive both gzip-encoded content and a plain content.
This is how to do it in apache2:
<IfModule mod_deflate.c>
#The following line is enough for .js and .css
AddOutputFilter DEFLATE js css
#The following line also enables compression by file content type, for the following list of Content-Type:s
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml
#The following lines are to avoid bugs with some browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
And here's how to add the Vary Accept-Encoding header: [src]
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
The Vary: header tells the that the content served for this url will vary according to the value of a certain request header. Here it says that it will serve different content for clients who say they Accept-Encoding: gzip, deflate (a request header), than the content served to clients that do not send this header. The main advantage of this, AFAIK, is to let intermediate caching proxies know they need to have two different versions of the same url because of such change.
I'm afraid Aularon didn't provide enough steps to complete the process. With a little trial and error, I was able to successfully enable Gzipping on my dedicated WHM server.
Below are the steps:
Run EasyApache within WHM, select Deflate within the Exhaustive Options list, and rebuild the server.
Once done, goto Services Configuration >> Apache Configuration >> Include Editor >> Post VirtualHost Include, select All Versions, and then paste the mod_headers.c and mod_headers.c code (listed above in Aularon's post) on top of on another within the input field.
Once saved, I was seeing a 75.36% data savings on average! You can run a before and after test by using this HTTP Compression tool to see your own results: http://www.whatsmyip.org/http_compression/
Hope this works for you all!
Matt
To gzip up your font files as well!
add "x-font/otf x-font/ttf x-font/eot"
as in:
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml x-font/otf x-font/ttf x-font/eot
This was driving me crazy, but it seems that aularon's edit was missing the colon after "Vary". So changing "Vary Accept-Encoding" to "Vary: Accept-Encoding" fixed the issue for me.
I would have commented below the post, but it doesn't seem like it will let me.
Anyhow, I hope this saves someone the same trouble I was having.
Many hours spent to clarify what was that. Please, read this post to get the advanced .HTACCESS codes and learn what they do.
You can use:
Header append Vary "Accept-Encoding"
#or
Header set Vary "Accept-Encoding"
if anyone needs this for NGINX configuration file here is the snippet:
location ~* \.(js|css|xml|gz)$ {
add_header Vary "Accept-Encoding";
(... other headers or rules ...)
}
No need to specify or even check if the file is/has compressed,
you can send it to every file, On every request.
It tells downstream proxies how to match future request headers to decide
whether the cached response can be used rather than requesting a fresh
one from the origin server.
<ifModule mod_headers.c>
Header unset Vary
Header set Vary "Accept-Encoding, X-HTTP-Method-Override, X-Forwarded-For, Remote-Address, X-Real-IP, X-Forwarded-Proto, X-Forwarded-Host, X-Forwarded-Port, X-Forwarded-Server"
</ifModule>
the unset is to fix some bugs in older GoDaddy hosting, optionally.