Custom Apache2 Directive for Gzip

Discussion in 'Server Operation' started by thisiszeev, Sep 3, 2024.

  1. thisiszeev

    thisiszeev Member HowtoForge Supporter

    Hi

    I am trying to optimize a site for a client. I am now trying to get the last ditched bit of sweet sweet load speed out of it...

    I am adding the following Apache2 Directive:


    Code:
    <IfModule mod_deflate.c>
        # Compress common text and markup formats
        AddOutputFilterByType DEFLATE text/html
        AddOutputFilterByType DEFLATE text/plain
        AddOutputFilterByType DEFLATE text/xml
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE text/markdown
        AddOutputFilterByType DEFLATE text/x-markdown
        AddOutputFilterByType DEFLATE text/x-shellscript    # For .sh files
        AddOutputFilterByType DEFLATE text/x-python         # For .py files
        AddOutputFilterByType DEFLATE application/sql       # For .sql files
        AddOutputFilterByType DEFLATE text/csv              # For .csv files
        AddOutputFilterByType DEFLATE text/tab-separated-values  # For .tsv files
        AddOutputFilterByType DEFLATE image/svg+xml
        AddOutputFilterByType DEFLATE application/xml
        AddOutputFilterByType DEFLATE application/xhtml+xml
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE application/x-javascript
        AddOutputFilterByType DEFLATE application/json
        AddOutputFilterByType DEFLATE application/ld+json
        AddOutputFilterByType DEFLATE application/x-httpd-php
        AddOutputFilterByType DEFLATE font/woff
        AddOutputFilterByType DEFLATE font/woff2
    
        # Exclude common binary, multimedia, and document formats from compression
        SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|mp3|mp4|avi|mov|pdf|mpg|mkv|aac|m4a|opus|doc|docx|xls|xlsx|odt|ods|webp|webm|gz|zip|arj|rar|bin|exe|msi|dmg|iso|tar|bz2|7z)$ no-gzip dont-vary
    
        # Ensure proxies cache both compressed and uncompressed versions
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
    
    
    The problem is when I enable that for the site, under Options > Apache Directive, then my Pingdom score suddenly drops to 76. The load time halfs, the amount of data downloaded doubles, and Pingdom takes my GZip score from 78 to 23?

    What am I missing here?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    So it might be that mod_deflate is already on, with better settings than what you use with this config. Or the delivered pages are already compressed and optimized by the CMS used in this site, so enabling these mod_deflate options just makes it worse.
     
    thisiszeev and ahrasis like this.
  3. thisiszeev

    thisiszeev Member HowtoForge Supporter

    I know it was on, but it wasn't carrying the scope for the clients content.

    But I managed to fix it.

    I was missing just one rule in the directive: AddOutputFilterByType DEFLATE text/javascript

    Page load time is now 1.28 seconds. I have never gotten below 2 seconds before.
     
    ahrasis and till like this.
  4. thisiszeev

    thisiszeev Member HowtoForge Supporter

    @till It would seem mundane to a mere peasant, but for sysadmins and web developers like us, that sweet sweet load time is a bigger high than any drug. Just shaving off 0.1seconds is a rush of endorphins.
     

Share This Page