Wie aktiviere ich die Gzip-Komprimierung?


12

Ich muss die Gzip-Komprimierung für ein Magento-Projekt einrichten. Ich habe viele Code in der .htaccessDatei in meinem Projekt ausprobiert , konnte Gzip jedoch nicht aktivieren.

Bitte geben Sie mir die richtige Lösung.


Sprechen Sie über die GZIP-Komprimierung, um die Leistung der Website zu verbessern?
— Mukesh

ja, sag mir wie man komprimiert
— Kishan Kothari

Haben Sie dieses Problem schon gelöst?
— Nitesh

Antworten:


9

Stellen Sie sicher, dass mod_deflatein Apache aktiviert ist. Sie können dies überprüfen, indem Sie eine info.phpDatei erstellen und aufrufen phpinfo();. Es werden die PHP / Apache-Spezifikationen des Servers im Browser ausgegeben. Vergessen Sie nicht, es zu entfernen, wenn Sie fertig sind!

Fügen Sie dann Folgendes zu Ihrer htaccessDatei hinzu

<IfModule mod_php5.c>
    ## enable resulting html compression
   php_flag zlib.output_compression on
</IfModule>

<IfModule mod_deflate.c>

    ## Force compression for mangled `Accept-Encoding` request headers
    <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.
    <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/vnd.geo+json" \
                                      "application/vnd.ms-fontobject" \
                                      "application/x-font-ttf" \
                                      "application/x-javascript" \
                                      "application/x-web-app-manifest+json" \
                                      "application/xhtml+xml" \
                                      "application/xml" \
                                      "font/eot" \
                                      "font/opentype" \
                                      "image/bmp" \
                                      "image/svg+xml" \
                                      "image/vnd.microsoft.icon" \
                                      "image/x-icon" \
                                      "text/cache-manifest" \
                                      "text/css" \
                                      "text/html" \
                                      "text/javascript" \
                                      "text/plain" \
                                      "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!).
    <IfModule mod_mime.c>
        AddEncoding gzip              svgz
    </IfModule>

</IfModule>

hallo sander code funktioniert nicht. Ich füge diesen Code hinzu, kann aber nicht g.zip aktivieren.
— Kishan Kothari

Ich brauche ein bisschen mehr, um dir zu helfen. Irgendwelche Fehler oder Hinweise, was nicht funktioniert?
— Sander Mangel

Website ist die richtige Arbeit, aber wenn ich von diesem Link checkgzipcompression.com als Show G.zip nicht aktivieren.
— Kishan Kothari,

Sind Sie sicher, dass mod_deflate aktiviert ist?
— Sander Mangel

Ja, sicher, dass der Knoten eingeschaltet ist
— Kishan Kothari
Durch die Nutzung unserer Website bestätigen Sie, dass Sie unsere Cookie-Richtlinie und Datenschutzrichtlinie gelesen und verstanden haben.
Licensed under cc by-sa 3.0 with attribution required.