Enabling deflate/gzip module with Apache


  • | 6284 points

    Re: Apache deflate/gzip module
    Hi I'm trying to get gzipping working with Laragon and PHP, but I don't think it's working.
    I have uncommted LoadModule deflate_module modules/mod_deflate.so from httpd.conf file, and copy-and-pasted this code into the bottom of that file too:

    <IfModule mod_deflate.c>
    
        # Force compression for mangled `Accept-Encoding` request headers
        #
        # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
        # https://calendar.perfplanet.com/2010/pushing-beyond-gzipping/
    
        <IfModule mod_setenvif.c>
            <IfModule mod_headers.c>
                SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
                RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
            </IfModule>
        </IfModule>
    
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    
        # Compress all output labeled with one of the following media types.
        #
        # https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype
    
        <IfModule mod_filter.c>
            AddOutputFilterByType DEFLATE "application/atom+xml" \
                                          "application/javascript" \
                                          "application/json" \
                                          "application/ld+json" \
                                          "application/manifest+json" \
                                          "application/rdf+xml" \
                                          "application/rss+xml" \
                                          "application/schema+json" \
                                          "application/geo+json" \
                                          "application/vnd.ms-fontobject" \
                                          "application/wasm" \
                                          "application/x-font-ttf" \
                                          "application/x-javascript" \
                                          "application/x-web-app-manifest+json" \
                                          "application/xhtml+xml" \
                                          "application/xml" \
                                          "font/eot" \
                                          "font/opentype" \
                                          "font/otf" \
                                          "font/ttf" \
                                          "image/bmp" \
                                          "image/svg+xml" \
                                          "image/vnd.microsoft.icon" \
                                          "text/cache-manifest" \
                                          "text/calendar" \
                                          "text/css" \
                                          "text/html" \
                                          "text/javascript" \
                                          "text/plain" \
                                          "text/markdown" \
                                          "text/vcard" \
                                          "text/vnd.rim.location.xloc" \
                                          "text/vtt" \
                                          "text/x-component" \
                                          "text/x-cross-domain-policy" \
                                          "text/xml"
    
        </IfModule>
    
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    
        # Map the following filename extensions to the specified encoding type in
        # order to make Apache serve the file types with the appropriate
        # `Content-Encoding` response header (do note that this will NOT make
        # Apache compress them!).
        #
        # If these files types would be served without an appropriate
        # `Content-Encoding` response header, client applications (e.g.: browsers)
        # wouldn't know that they first need to uncompress the response, and thus,
        # wouldn't be able to understand the content.
        #
        # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
        # https://httpd.apache.org/docs/current/mod/mod_mime.html#addencoding
    
        <IfModule mod_mime.c>
            AddEncoding gzip              svgz
        </IfModule>
    
    </IfModule>
    

    BUt when I make a request I don't see any header indicating the results are gzipped or anything. Any ideas waht I"m missing?


  • administrators
    | 123538 points


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.