0

I use the following quip on a htaccess file to enable compression on a GoDaddy server;

####################
# GZIP COMPRESSION #
####################
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip

This is a quip I've taken from another question on StackOverflow a long time ago. Up until recently this worked perfectly. Now it simply refuses to work, despite mod_deflate being enabled on WHM, websites like https://checkgzipcompression.com/ will tell me that the website isn't compressed. I cannot enable compression on this server unless I use ob_gzhandler in PHP as follows;

if(!ob_start("ob_gzhandler")) ob_start();

This isn't an optimal solution.

I have a VPS on which I have a fairly similar apache/php installation, and it hosts the same version of the website hosted on the GoDaddy server, having the exact same files, including the htaccess with the gzip compression quip, and it works without requiring ob_gzhandler.

I've tried contacting GoDaddy, but they have been most unhelpful telling me to "verify the htaccess" instead of doing anything, and I've considered migrating my entire installation to another service provider.

Is there anything extra I should verify?

Sefam
  • 1,712
  • 2
  • 23
  • 40
  • Do you have shell access? Does `apache2ctl -M` show mod_deflate? – Jeremy Harris Jan 19 '17 at 18:50
  • I don't think I have shell access I'm afraid. EasyApache4 in WHM shows mod_deflate as enabled. – Sefam Jan 19 '17 at 18:53
  • Does it work if you comment out the `BrowserMatch` and `SetEnvIfNoCase` sections? I see a lot of "no-gzip" options...might try to rule out something is getting matched. – Jeremy Harris Jan 19 '17 at 18:55
  • Nope, I've removed everything but SetOutputFilter DEFLATE and AddOutputFilterByType (the rest here) and it still doesn't work. – Sefam Jan 19 '17 at 18:58
  • I managed to get root shell access, although apache2ctl doesn't work, I used apachectl -M. deflate_module is one of the modules loaded, although it's specified it's "shared" rather than static. – Sefam Jan 19 '17 at 19:04

1 Answers1

0

Login to WHM -> Account Information ->List Accounts. Click on the CP icon for that account (the one with the desired website). Once you are in cPanel search for Optimize Website.

By default the Gzip compression is disabled.

Enable it for all the content or just for specific content. Then re-check your website on https://checkgzipcompression.com/ and it should show you that the gzip compression is enabled.

Then you can use the desired htaccess rules for mod_deflate.

Bogdan Stoica
  • 4,349
  • 2
  • 23
  • 38