Reputation: 1937
I have classic shared hosting(apache). In phpinfo() it's both enabled.
gzip compression enabled
I tried to use this:
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
Also this:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/x-javascript application/javascript text/javascript text/css text/html text/xml
</IfModule>
But it's not working for me. Response headers are:
HTTP/1.1 200 OK
Date: Mon, 03 Aug 2015 15:29:08 GMT
Server: Apache
Last-Modified: Mon, 03 Aug 2015 14:28:34 GMT
ETag: "64325f33-1ebd5-51c68fc093cbc"
Accept-Ranges: bytes
Cache-Control: max-age=604800
Expires: Mon, 10 Aug 2015 15:29:08 GMT
Vary: Accept-Encoding
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: application/javascript
Transfer-Encoding: chunked
so it's missing Content-Encoding gzip
. If I run my script using this it shows me
It's GZIP Enabled.72.9% Was saved by compressing this page with GZIP.
But in my code it's not working(there's no compression). What should I do/try?
Upvotes: 0
Views: 1654
Reputation: 714
I think that compression is working OK. Server does not respond as expected because, according RFC, you need to specify that you want to have compressed response by adding Accept-Encoding header with one of supported content-codings to your request.
Accept-Encoding: gzip, deflate
Upvotes: 1