6

I have prepared a server to run a Magento instance with: Apache + Php-FPM + APC

The problem I have is that Apache is not compressing the HTML output from the Magento PHP scripts.

In my .htaccess I have:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml AddOutputFilterByType DEFLATE application/javascript application/x-javascript AddOutputFilterByType DEFLATE application/x-httpd-php 

I also tried compressing all with:

SetOutputFilter DEFLATE 

But I had no luck.

Zlib compression is disabled:

php_flag zlib.output_compression on 

My guess is that this have something to do with Php-FPM or APC, but I'm not sure about what the problem is.

The mime-type returned for the uncompressed pages is:

Content-Type: text/html; charset=UTF-8 

Any ideas?

UPDATE: The problems seems to be with anything that is processed by PHP, if I copy the html output to a .html file and then fetch it, it will be compressed, if I rename the same file to .php and fetch it the output won't be compressed. Here are the headers:

[[RESPONSE HEADER HTML FILE]]

Date Fri, 29 Aug 2014 20:03:13 GMT Content-Encoding gzip Last-Modified Fri, 29 Aug 2014 19:53:19 GMT Server Apache/2.2.15 (CentOS) ETag "24002f-34e71-501ca0144a75d" Vary Accept-Encoding,User-Agent Content-Type text/html Cache-Control max-age=10800 Connection Keep-Alive Accept-Ranges bytes Keep-Alive timeout=5, max=100 Content-Length 20884 Expires Fri, 29 Aug 2014 23:03:13 GMT 

[[RESPONSE HEADER PHP FILE]]

Date Fri, 29 Aug 2014 20:05:19 GMT Server Apache/2.2.15 (CentOS) Connection Keep-Alive Keep-Alive timeout=5, max=100 Transfer-Encoding chunked Content-Type text/html; charset=UTF-8 

And the request headers:

[[REQUEST HEADER HTML FILE]]

Pragma no-cache Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding gzip,deflate,sdch Host dev.go-parts.com Accept-Language en-US,en;q=0.8 User-Agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Cache-Control no-cache Connection keep-alive 

[[REQUEST HEADER PHP FILE]]

Pragma no-cache Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding gzip,deflate,sdch Host dev.go-parts.com Accept-Language en-US,en;q=0.8 User-Agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Cache-Control no-cache Connection keep-alive 
5
  • What were the full request / response headers when you tested if compression works? Commented Aug 29, 2014 at 19:56
  • @TeroKilkanen I have added the response headers for 2 pages with the same content one with HTML and the other with PHP extension, the first on is compressed and the other one no. Any idea what I can do? =( Commented Aug 29, 2014 at 20:09
  • What are the request headers for these requests? Commented Aug 29, 2014 at 20:11
  • @TeroKilkanen I added the request headers too. Commented Aug 29, 2014 at 20:19
  • The apache repsonse headers seem to indicate you are not using mod_php, but could be restricted by configuration. Can you confirm how you are executing your PHP? (mod_php, as a CGI, fastcgi, fcgid or proxying to FPM) If you are proxying to a fastCGI server or to an FPM pool then apache itself is not mapping the request to the file system and so your htaccess file would not be read. Commented Sep 27, 2016 at 17:35

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.