6

I am about 48 hours into trying to solve a gzip deflate issue and realize I may need to ask for help, hehehe.

I have finally gotten the deflate module enabled on my shared Unix server via .htaccess after realizing I needed to turn on compression in my php.ini file.

PageSpeed is telling me that my root HTML is encoded with gzip for the site and I am getting 77.3% compression for the Wordpress site theoleandersofsanleon.com but none of the files in any sub directories are being compressed (mainly css and js files in my wordpress directory and it's sub directories).

I didn't think it was necessary but I went ahead and tried to use the directive Directory and then the directive Location to no avail.

I put a phpinfo.php file in the root if you need to see that for any server specs.

Here is what I have in my .htaccess file for both my htdocs directory and wordpress directory:

<IfModule mod_deflate.c>
# Insert filters
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/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Please let me know if you need any more information, and thank you very much for any help, it will be greatly appreciated and I will be able to start letting my hair grow back 8-)

  • Thanks for responding. I read up on documentation about Gzip and deflate for about 12 hours and every single thing I read was in agreement that Gzip was the old version (for use with Apache 1.3) and deflate was new with Gzip being deprecated after Apache 2.0 However, that doesn't mean all of these docs aren't wrong. I enabled compression in .htaccess at least 5 different ways, and until I turned zlip output on it would not work. I have also throughout every step of the process deleted browser cache. Do you have any information on the question I asked? Thanks again for responding. – Will Richards Dec 18 '12 at 17:06
  • Sorry. You are correct. mod_deflate is prefered to mod_gzip. I don't know why I wrote that, although in my defense mod_deflate actually uses gzip contrarily to its name. I'll delete my comment, as to not confuse anyone else. – Gerben Dec 18 '12 at 21:56
  • No problemo. There was a strange thing though, I looked in my php.ini and it said mod_deflate was installed even though if you noticed, my server is running Apache 1.3.42. Either way, I ended up removing the directives from my htaccess and installed WT3C. Now it shows that it is using Gzip (which makes sense for 1.3) and is compressing all my css and js, but not my homepage html, LOL! So now I have the exact opposite problem as what I originally had 8-) Oh well, the site is a little faster now, we'll see if I can't get both sides of the equation to work eventually... – Will Richards Dec 18 '12 at 22:02
  • Aha. I was just checking the website, and the css was returned with gzip compression. But why still use apache 1.3.42? That version is almost 3 years old. – Gerben Dec 18 '12 at 22:10

1 Answers1

0

Try this in your top level .htaccess file. This the content generated when using the optimiser in cPanel.

<IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
  <IfModule mod_setenvif.c>
    # 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 to get the desired effect:
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

    # Don't compress images
    SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
  </IfModule>

  <IfModule mod_headers.c>
    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
  </IfModule>
</IfModule>
Mark
  • 3,005
  • 1
  • 21
  • 30
  • Hi Mark, Thanks for the input. Looks like all of that was covered in the htaccess file after installing WT3C. Here is my htaccess as it stands now (still only compressing css and js, gzip test fails): http://theoleandersofsanleon.com/stack/htaccessStack.txt Thanks again. – Will Richards Jan 07 '13 at 23:44
  • 1
    There doesn't look to be anything wrong with your htaccess file that I can see. The best thing I can think to suggest is update Apache, but to be honest that's just something I'd try, not utterly convinced it'll make any difference :) – Mark Jan 08 '13 at 21:53
  • Awesome. Thanks for checking Mark. Really appreciate you. I will consult with my host to see why they are running old Apace and go from there. – Will Richards Jan 14 '13 at 17:26
  • @WillRichards Did you manage to resolve this? I'm having the same issue and couldn't work it out. – user1448031 Nov 08 '17 at 00:52