I have an inherited Apache 2.2.17 server running on Ubuntu that I need to enable compression on. I have ensured the mod is loaded:
apachectl -t -D DUMP_MODULES
Loaded Modules:
...
deflate_module (shared)
headers_module (shared)
setenvif_module (shared)
...
I have then set http.conf
with the following rules:
<IfModule deflate_module>
SetOutputFilter DEFLATE
<IfModule setenvif_module>
# Netscape 4.x has some problems
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48, the above regex won’t work. You can use the following
# workaround (comment the above line and uncomment the below line) to get the desired effect:
# BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don’t compress already-compressed files
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(?:avi|mov|mp3|mp4|rm|flv|swf|mp?g)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary
</IfModule>
<IfModule headers_module>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
Now if I retrieve the HEAD
using python or curl I get a gzip response (this is just for a .txt
file but is consistent accross the site):
Date: Mon, 06 May 2013 11:53:31 GMT
Server: Apache/2.2.17 (Ubuntu)
Last-Modified: Sun, 05 May 2013 12:37:23 GMT
ETag: "2412002-129c6-4dbf7d88766c0"
Accept-Ranges: bytes
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 32607
Content-Type: text/plain
However if I do a POST
or GET
, I do not get gzip back:
Date: Mon, 06 May 2013 11:53:25 GMT
Server: Apache/2.2.17 (Ubuntu)
Last-Modified: Sun, 05 May 2013 12:37:23 GMT
ETag: "2412002-129c6-4dbf7d88766c0"
Accept-Ranges: bytes
Vary: Accept-Encoding,User-Agent
Content-Type: text/plain
Content-Length: 76230
UPDATE:
Here are the headers from Firefox 20
. Firebug & Google confirm gzip is being requested:
Date: Tue, 07 May 2013 16:57:01 GMT
Server: Apache/2.2.17 (Ubuntu)
X-Powered-By: PHP/5.3.5-1ubuntu7.10
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding,User-Agent
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 19922
This has been frustrating me for a few days now and any help would be much appreciated.
Thanks