Jump to content

Gzip only works on non www. site


Tommy
 Share

Recommended Posts

Hi all

I am having what I think is a strange problem with Gzip, but I am not sure whether it is something related to Processwire or not. The compression appears to work correctly on http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

And the following for gzip

<IfModule mod_deflate.c>
AddOutputFilter DEFLATE js css
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

I would be gratefull if anyone could point me in the right direction as to why only the URL that is being redirected  seems to show gzip working.

Thanks

Tommy

Link to comment
Share on other sites

Hi Macrura

Thanks for the reply, yes I have tested on www.gziptest.com and also on my local computer using curl.

If I comment out the redirect, gzip does not appear to work on any of the url's http://mysite.com or http://www.mysite.com

My .htaccess is the standard one installed with Processwire with the only addition being to implement the mod_deflate

I am trying to work out whether this is a server issue or some issue with Processwire or .htaccess

Thanks

Tommy

Link to comment
Share on other sites

Have you checked that mod_deflate is actually enabled?

Another possibility is that Apache is running behind a nginx frontend. When this is the case your hosting provider needs to configure nginx to do gzip compression.

Link to comment
Share on other sites

Hi SiNNuT, thanks for your reply.

I have checked with host and mod_deflate is enabled, they didn't mention anything about nginx.

The compression appears to work on whichever version is being rewritten (i.e non www to www)

This curl output shows gzip working on the 301 Moved Permanently version

HTTP/1.1 301 Moved Permanently
Date: Tue, 30 Jun 2015 12:07:18 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Location: http://www.motoringstuff.net/
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 20
Content-Type: text/html; charset=iso-8859-1

and not working on the 200 OK version

HTTP/1.1 200 OK
Date: Tue, 30 Jun 2015 12:07:24 GMT
Server: Apache
Set-Cookie: wire=4ikn9vccnl6si2gj2vurg116g1; path=/; HttpOnly
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
Content-Type: text/html; charset=utf-8

I have tried putting the AddOutputFilterByType DEFLATE command at various places in the .htaccess file.

I am not sure how to trace where the problem lies as my host says it must be something in my .htaccess that is causing the issue.

Only other thing is that I am running PHP Fast CGI, could this be of any relevance or related?

Any ideas of things to try would be much appreciated.

Tommy

Link to comment
Share on other sites

Just to update, I have now discovered that the only content that appears not to be getting compressed is any output from PHP scripts.

if i check  index.html, anyfile.txt they both show that gzip is working

But when I check index.php or any php file result shows gzip is not working.

This appears strange as the output from both of these should be text/html

Tommy

Link to comment
Share on other sites

Thanks for the replies.

I now have compression working but I have still to fully test and I am still not really sure what is happening exactly.

It seems that my server is automatically set for mod_deflate, so I dont need to add it in the .htaccess file.

mod_deflate does not seem to compress any file that is output from PHP, no matter what file types I add in .htaccess

I have now added "php_flag zlib.output_compression on" to my .htaccess and this seems to compress all PHP output, with mod_deflate compressing any static content.

Thanks again

Tommy

Update: This did not cure my issues and I ended changing from FastCGI to mod_php and everything works as expected. It appears that the way scripts are handled in FastCGI was causing the issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...