We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28120
    • 380 Posts
    I've got a client who's obsessing about pagespeed scores. I've told her it's about as useful as a diesel emission test but I can cheat the results if that's what she wants!

    However I would like to understand compression. I was running without compression. I've now switched compression on and all warnings have gone except on the root which I'm assuming is index.php.

    The code I've added to .htaccess is

    <IfModule mod_deflate.c>
      # Compress HTML, CSS, JavaScript, Text, XML and fonts
      AddOutputFilterByType DEFLATE application/javascript
      AddOutputFilterByType DEFLATE application/rss+xml
      AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
      AddOutputFilterByType DEFLATE application/x-font
      AddOutputFilterByType DEFLATE application/x-font-opentype
      AddOutputFilterByType DEFLATE application/x-font-otf
      AddOutputFilterByType DEFLATE application/x-font-truetype
      AddOutputFilterByType DEFLATE application/x-font-ttf
      AddOutputFilterByType DEFLATE application/x-javascript
      AddOutputFilterByType DEFLATE application/x-httpd-php
      AddOutputFilterByType DEFLATE application/x-httpd-fastphp
      AddOutputFilterByType DEFLATE application/xhtml+xml
      AddOutputFilterByType DEFLATE application/xml
      AddOutputFilterByType DEFLATE font/opentype
      AddOutputFilterByType DEFLATE font/otf
      AddOutputFilterByType DEFLATE font/ttf
      AddOutputFilterByType DEFLATE image/svg+xml
      AddOutputFilterByType DEFLATE image/x-icon
      AddOutputFilterByType DEFLATE text/css
      AddOutputFilterByType DEFLATE text/html
      AddOutputFilterByType DEFLATE text/javascript
      AddOutputFilterByType DEFLATE text/plain
      AddOutputFilterByType DEFLATE text/xml
    
      # Remove browser bugs (only needed for really old browsers)
      BrowserMatch ^Mozilla/4 gzip-only-text/html
      BrowserMatch ^Mozilla/4\.0[678] no-gzip
      BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
      Header append Vary User-Agent
    </IfModule>


    How to I get compression to work on index.php?
      • 33983 ☆ A M B ☆
      • 181 Posts
      Never tried it, I don't use apache any more, I use nginx. I would suggest looking into: Statcache: http://modx.com/extras/package/statcache. When set up correctly you don't need to compress any PHP file as the server will serve HTML files once it is cached/ran once. This will be the fastest you can make your server to client response time. Statcache docs: https://github.com/opengeek/statcache/wiki
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        You are not serving .php files. The index.php file is passed on to PHP (whether as an Apache module or a CGI/FastCGI process) to process directly on the server, and it is its output that is returned to the web server and served as the request response. If the web server does somehow compress a .php file before passing it on to the PHP program, it would only slow things down as the PHP program has to expand it before it can process it.

        Compressing images and PDF files is an exercise in redundancy, they are already compressed all by themselves. You're just putting an extra load on the server to no purpose.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org