We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26575
    • 57 Posts
    I'm currently experiencing some wired caching behavior on a client server.

    When I enable zlib.output_compression for modx resources the server answers
    - first with an empty response (Error 324 (net::ERR_EMPTY_RESPONSE))
    - after a reload I get some ascii code as output (see image: http://cl.ly/Cjte),
    - after one more reload I get my html file as expected (the modx resource is now cached!)

    When I clear the modx cache it starts again (empty response -> ascii code -> html).


    The only affects resources from modx. Static html or php files work like expected.


    I'm on a Mac using Google Chrome. Server is a "Managed Server" from Hetzner (Germany).
    phpinfo can be found here: http://cl.ly/CkM8

    .htaccess file (excerpt):
    # ----------------------------------------------------------------------
    # Gzip compression
    # ----------------------------------------------------------------------
    
    php_flag zlib.output_compression On
    php_value zlib.output_compression_level 5
    
    <IfModule mod_deflate.c>
    <IfModule mod_setenvif.c>
      <IfModule mod_headers.c>
        SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s,?\s(gzip|deflate)?|X{4,13}|~{4,13}|-{4,13})$ HAVE_Accept-Encoding
        RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
      </IfModule>
    </IfModule>
    
    <IfModule filter_module>
      FilterDeclare   COMPRESS
      FilterProvider  COMPRESS  DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
      FilterProvider  COMPRESS  DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
      FilterChain     COMPRESS
      FilterProtocol  COMPRESS  change=yes;byteranges=no
    </IfModule>
    
    <IfModule !mod_filter.c>
      AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
      AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript 
      AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
    </IfModule>
    
      <FilesMatch "\.(ttf|otf|eot|svg)$" >
        SetOutputFilter DEFLATE
      </FilesMatch>
    </IfModule>

    This question has been answered by Seel-Media. See the first response.

      christian seel - www.christianseel.com
      web developer & designer at chsmedien.de
      twitter: @christianseel / @chsmedien
    • This sounds like an issue where the compressed file is being sent to the browser without the appropriate header information to tell it to decompress. Have your hosting provide set the output buffer

      try setting the actual buffer size vs. just "On" and see if that helps

      php_flag zlib.output_compression 16386

        Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
        Visit CharlesMx.com for latest news and status updates.
        • 26575
        • 57 Posts
        Hi charless, thanks for your idea. When I try to set a buffer size the output is NOT compressed. I've tried 16386 and 4096.

        I read it might be compressed twice. It's like this Issue from Drupal: http://drupal.org/node/121820

        I also tried using Firefox, there are no problems! It's just on Chrome. (Didn't test Opera or IE) [Issue also exists in Firefox. So it seems to be not browser specific.] [ed. note: Seel-Media last edited this post 12 years, 4 months ago.]
          christian seel - www.christianseel.com
          web developer & designer at chsmedien.de
          twitter: @christianseel / @chsmedien
        • Looks like you are compressing with the web server and PHP, likely the problem. Choose one.
            • 26575
            • 57 Posts
            zlib.output_compression is one, but when I disable it, the output is not compressed.

            Whats the other one...? Does MODX do any compression of uncached files? (Because this issue seems to be just with not [jet] cached resources.
              christian seel - www.christianseel.com
              web developer & designer at chsmedien.de
              twitter: @christianseel / @chsmedien
            • Quote from: Seel-Media at Dec 20, 2011, 02:05 PM
              zlib.output_compression is one, but when I disable it, the output is not compressed.
              How are you disabling it? Are you sure the php.ini does not have it on or are you setting it Off in the .htaccess?

              Quote from: Seel-Media at Dec 20, 2011, 02:05 PM
              Whats the other one...? Does MODX do any compression of uncached files? (Because this issue seems to be just with not [jet] cached resources.
              The other is the webserver compression being applied via that .htaccess excerpt you provided. MODX does not do any automatic compression like Drupal does as described in the link you provided.
                • 26575
                • 57 Posts
                Quote from: opengeek at Dec 20, 2011, 04:17 PM
                How are you disabling it? Are you sure the php.ini does not have it on or are you setting it Off in the .htaccess?
                Default setting for zlib.output_compression in the php.ini is off. So when I delete
                php_flag zlib.output_compression On

                from my htaccess it's off and when I test if the output is gzipped - it's not.

                Quote from: opengeek at Dec 20, 2011, 04:17 PM
                The other is the webserver compression being applied via that .htaccess excerpt you provided. MODX does not do any automatic compression like Drupal does as described in the link you provided.
                I thought DEFLATE is just for non-php files? So I have to add zlib.output_compression for php files. Not right? Also removing this mod_deflate part does not solve my problem.
                  christian seel - www.christianseel.com
                  web developer & designer at chsmedien.de
                  twitter: @christianseel / @chsmedien
                • Quote from: Seel-Media at Dec 20, 2011, 09:14 PM
                  Quote from: opengeek at Dec 20, 2011, 04:17 PM
                  The other is the webserver compression being applied via that .htaccess excerpt you provided. MODX does not do any automatic compression like Drupal does as described in the link you provided.
                  I thought DEFLATE is just for non-php files? So I have to add zlib.output_compression for php files. Not right? Also removing this mod_deflate part does not solve my problem.
                  I thought it might be the culprit because it was being applied based on content types, of which MODX can serve any...

                  But if that is not the issue, perhaps it's not related to output compression at all.
                  • discuss.answer
                    • 26575
                    • 57 Posts
                    Got support from the hoster. No Idea why zlib.output_compression doesn't work as expected.
                    BUT replacing it with
                    AddHandler fcgid-script .php .php5
                    FCGIWrapper /home/httpd/cgi-bin/php5-fcgi-starter.fcgi .php
                    FCGIWrapper /home/httpd/cgi-bin/php5-fcgi-starter.fcgi .php5
                    AddOutputFilter DEFLATE html php css js

                    solved all problems! =)
                      christian seel - www.christianseel.com
                      web developer & designer at chsmedien.de
                      twitter: @christianseel / @chsmedien