• Hi there,

    When I run a speed test on my site, it says GZIP is not enabled.

    Can someone advise the best way to enable this? I have all the various settings enabled in WP Super Cache, and also have the .htaccess file updated as per the guidelines on the settings page.

    Tested using:
    https://tools.pingdom.com

    URL: https://corkcityfc.ie/home/

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Compression and leverage browser caching for static files is related to server rules (static files are served directly from the server without including WordPress).

    You need to add rules into .htaccess. An example is (it isn’t perfect, but I think that it includes all file types):

    ########## Begin - Optimal default expiration time
    ## Note: this might cause problems and you might have to comment it out by
    ## placing a hash in front of this section's lines
    <IfModule mod_expires.c>
        # Enable expiration control
        ExpiresActive On
    
        # Enable ETag
        FileETag MTime Size
    
        # Define font file types
        AddType application/x-font-woff woff woff2
        AddType application/x-font-ttf ttf ttc
    
        # Define image file types
        AddType image/webp webp webp
    
        # Default expiration: 1 hour after request
        ExpiresDefault "now plus 1 hour"
    
        # CSS and JS expiration: 1 week after request
        ExpiresByType text/css "now plus 1 week"  
        ExpiresByType text/javascript "now plus 1 week"
        ExpiresByType text/x-javascript "now plus 1 week"
        ExpiresByType application/javascript "now plus 1 week"
        ExpiresByType application/x-javascript "now plus 1 week"
    
        # Font files expiration: 1 month after request
        ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
        ExpiresByType application/x-font-ttf "access plus 1 month"
        ExpiresByType application/x-font-opentype "access plus 1 month"
        ExpiresByType application/x-font-woff "access plus 1 month"
        ExpiresByType image/svg+xml "access plus 1 month"
    
        # Image files expiration: 1 month after request
        ExpiresByType image/bmp "now plus 1 month"
        ExpiresByType image/gif "now plus 1 month"
        ExpiresByType image/jpeg "now plus 1 month"
        ExpiresByType image/jp2 "now plus 1 month"
        ExpiresByType image/pipeg "now plus 1 month"
        ExpiresByType image/png "now plus 1 month" 
        ExpiresByType image/tiff "now plus 1 month"
        ExpiresByType image/webp "now plus 1 month"
        ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
        ExpiresByType image/x-icon "now plus 1 month"
        ExpiresByType image/ico "now plus 1 month" 
        ExpiresByType image/icon "now plus 1 month"
        ExpiresByType text/ico "now plus 1 month"
        ExpiresByType application/ico "now plus 1 month"
        ExpiresByType image/vnd.wap.wbmp "now plus 1 month"
        ExpiresByType application/vnd.wap.wbxml "now plus 1 month"
        ExpiresByType application/smil "now plus 1 month"
        
        # Audio files expiration: 1 month after request
        ExpiresByType audio/basic "now plus 1 month"   
        ExpiresByType audio/mid "now plus 1 month"     
        ExpiresByType audio/midi "now plus 1 month" 
        ExpiresByType audio/mpeg "now plus 1 month"
        ExpiresByType audio/x-aiff "now plus 1 month"
        ExpiresByType audio/x-mpegurl "now plus 1 month"
        ExpiresByType audio/x-pn-realaudio "now plus 1 month"
        ExpiresByType audio/x-wav "now plus 1 month"
    
        # Movie files expiration: 1 month after request
        ExpiresByType application/x-shockwave-flash "now plus 1 month"
        ExpiresByType x-world/x-vrml "now plus 1 month"
        ExpiresByType video/x-msvideo "now plus 1 month"
        ExpiresByType video/mpeg "now plus 1 month"
        ExpiresByType video/mp4 "now plus 1 month" 
        ExpiresByType video/quicktime "now plus 1 month"
        ExpiresByType video/x-la-asf "now plus 1 month" 
        ExpiresByType video/x-ms-asf "now plus 1 month" 
    
        # Disable caching for scripts and other dynamic files
        <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
            ExpiresActive Off
        </FilesMatch>
    
    </IfModule>
    ########## End - Optimal expiration time
    
    ########## Begin - Automatic compression of resources
    # Compress text, html, javascript, css, xml
    # May kill access to your site for old versions of Internet Explorer
    # The server needs to be compiled with mod_deflate otherwise it will send HTTP 500 Error.
    # mod_deflate is not available on Apache 1.x series. Can only be used with Apache 2.x server.
    # AddOutputFilterByType is now deprecated by Apache. Use mod_filter in the future.
    <IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript text/javascript
    </IfModule>
    ########## End - Automatic compression of resources
    

    If you have installed nginx then you should find similar rules.

    Thread Starter DC_CCFC

    (@tgo_dc)

    Thanks!

    I’ve added this now.

    Hope it works! 🙂

    Will test again in one hour.

    It seems that doesn’t work.

    $ curl -i -s -H 'Accept-Encoding: br,gzip,deflate' https://www.corkcityfc.ie/home/wp-includes/css/dist/block-library/style.min.css
    HTTP/1.1 200 OK
    Server: nginx
    Date: Mon, 11 Mar 2019 12:49:04 GMT
    Content-Type: text/css
    Content-Length: 25242
    Last-Modified: Fri, 08 Mar 2019 20:53:12 GMT
    Connection: keep-alive
    Cache-Control: max-age=3, must-revalidate
    Expires: Mon, 18 Mar 2019 12:49:04 GMT
    ETag: "5c82d638-629a"
    X-Powered-By: PleskLin
    Accept-Ranges: bytes
    
    .wp-block-audio figcaption
    ...
    

    Headers show nginx and Plesk as server. I’m not sure is it reason. You could see https://support.plesk.com/hc/en-us/articles/213380049-How-to-enable-gzip-compression-in-nginx-on-a-Plesk-server or contact your host for more details.

    Thread Starter DC_CCFC

    (@tgo_dc)

    Okay, I’ve edited my nginx ad added the below to the additional directives section.

    Will see how this goes! 🙂

    gzip on;
    gzip_disable &quot;MSIE [1-6]\\.(?!.*SV1)&quot;;
    gzip_proxied any;
    gzip_comp_level 5;
    gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/rss+xml text/javascript image/x-icon image/bmp image/svg+xml;
    gzip_vary on;
    • This reply was modified 7 years, 3 months ago by DC_CCFC.
    Thread Starter DC_CCFC

    (@tgo_dc)

    Tested here, and it says GZIP is enabled at 85% compression:
    https://www.giftofspeed.com/gzip-test/

    I think I’m good now? What do you think?

    It seems that works.

    $ curl -i -s -H 'Accept-Encoding: br,gzip,deflate' https://www.corkcityfc.ie/home/wp-includes/css/dist/block-library/style.css
    HTTP/1.1 200 OK
    Server: nginx
    Date: Mon, 11 Mar 2019 14:08:21 GMT
    Content-Type: text/css
    Last-Modified: Fri, 08 Mar 2019 20:53:12 GMT
    Transfer-Encoding: chunked
    Connection: keep-alive
    Vary: Accept-Encoding
    ETag: W/"5c82d638-79d7"
    X-Powered-By: PleskLin
    Content-Encoding: gzip
    
    ^_<8B>^H^@^@^@^@^@^@...
    

    I didn’t test all files. Also you need to check that serving supercache files works correctly (without double gzip compression). I didn’t notice it, but you need to double check it (you will see message in browser, so you could easy notice it). Please try different browsers for URLs which are already cached.

    Thread Starter DC_CCFC

    (@tgo_dc)

    Thanks. I will leave it 2-3 hours and test a number of pages in different browsers.

    Is it possible WP Super Cache makes setup easier for those using nginx instead of Apache?

    Piani

    (@webbmasterpianise)

    removed

    I’ve checked your website and it seems that compression works as should.

    I can’t answer what we could improve related to nginx, but maybe we could try to write better instructions for setup. Also, it’s tricky because there should be a lot of testing. I’ll try to do something if I find enough spare time.

    Thread Starter DC_CCFC

    (@tgo_dc)

    Great, thanks

    What site do you use to test for compression?

    I have used Pingdom, but it’s giving incorrect info I believe.

    GTmetrix shows URLs where compression don’t work. It requires patience because you need to wait few minutes, but I think that shows more details than pingdom.

    Enable compression for the following resources to reduce their transfer size by 49.3KiB (76% reduction).

    Maybe you could try to replace these external files. I don’t know. I use CNDJS to optimize loading scripts/styles (if they exist on cdnjs).

    Thread Starter DC_CCFC

    (@tgo_dc)

    Thanks! I removed the top two, they’re out-dated plugins I no longer use. Should help somewhat.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘GZIP Not enabled?’ is closed to new replies.