Question

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.

Was it helpful?

Solution 4

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.

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top