Tommy Posted June 29, 2015 Share Posted June 29, 2015 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 cssAddOutputFilterByType DEFLATE text/html text/plain text/xml application/xmlBrowserMatch ^Mozilla/4 gzip-only-text/htmlBrowserMatch ^Mozilla/4\.0[678] no-gzipBrowserMatch \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 More sharing options...
Macrura Posted June 29, 2015 Share Posted June 29, 2015 have you tried testing the www url with a gzip testing service? Link to comment Share on other sites More sharing options...
Tommy Posted June 29, 2015 Author Share Posted June 29, 2015 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 More sharing options...
Macrura Posted June 29, 2015 Share Posted June 29, 2015 gzip works 100% on all of my PW sites. So i can only conclude it is your hosting provider. Link to comment Share on other sites More sharing options...
Tommy Posted June 30, 2015 Author Share Posted June 30, 2015 Thanks, I will speak to them to try and resolve the issue. Link to comment Share on other sites More sharing options...
SiNNuT Posted June 30, 2015 Share Posted June 30, 2015 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 More sharing options...
Tommy Posted June 30, 2015 Author Share Posted June 30, 2015 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 PermanentlyDate: Tue, 30 Jun 2015 12:07:18 GMTServer: ApacheX-Frame-Options: SAMEORIGINLocation: http://www.motoringstuff.net/Vary: Accept-EncodingContent-Encoding: gzipContent-Length: 20Content-Type: text/html; charset=iso-8859-1 and not working on the 200 OK version HTTP/1.1 200 OKDate: Tue, 30 Jun 2015 12:07:24 GMTServer: ApacheSet-Cookie: wire=4ikn9vccnl6si2gj2vurg116g1; path=/; HttpOnlyExpires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0Pragma: no-cacheContent-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 More sharing options...
Tommy Posted June 30, 2015 Author Share Posted June 30, 2015 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 More sharing options...
SiNNuT Posted June 30, 2015 Share Posted June 30, 2015 Running out of ideas here. Have you tried removing the <IfModule mod_deflate.c> and </IfModule> lines and see what that gives? Check the Apache error log. On a side note: you should check the h5bp Apache server config for a more complete/up to date deflate stuff https://github.com/h5bp/server-configs-apache Link to comment Share on other sites More sharing options...
Tommy Posted June 30, 2015 Author Share Posted June 30, 2015 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 More sharing options...
SiNNuT Posted June 30, 2015 Share Posted June 30, 2015 My googling led to the zlib compression solution as well. Not sure as the why, but probably it has got something to do with fastcgi and/or config. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now