Сжатие WordPress не работает на localhost, XAMPP - PullRequest
0 голосов
/ 09 июля 2020

Мне нужна помощь в оптимизации скорости WordPress с помощью .htaccess.

На данный момент веб-сайт все еще работает на localhost, XAMPP, Apache v3.2.4.

Что я делал / пробовал:

  • включить GZip в .htaccess
  • включить мод deflate в .htacess
  • поместить .htaccess в WordPress root каталог

Google Lighthouse Speed Test с помощью инструментов Chrome dev не обнаруживает:

  • Сжатие (сообщение : Включить сжатие текста )

Когда я просматриваю response header с помощью инструментов разработчика, там нет записи cache-control: ....

Я был бы признателен за некоторую помощь по как исправить эти проблемы. Я полагаю, что где-то в своей настройке я ошибся, но я не уверен, где.

Итак, вот что я сделал для СЖАТИЯ в .htacces:

<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>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/opentype
    # For Olders Browsers Which Can't Handle Compression
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

<IfModule mod_headers.c>

     RewriteCond %{HTTP:Accept-Encoding} gzip
     RewriteCond %{REQUEST_FILENAME}\.gz -f
     RewriteRule \.(css|ics|js|json|html|svg)$ %{REQUEST_URI}.gz [L]

     # Prevent mod_deflate double gzip
     RewriteRule \.gz$ - [E=no-gzip:1]

     <FilesMatch "\.gz$">

         # Serve correct content types
         <IfModule mod_mime.c>
             # (1)
             RemoveType gz

             # Serve correct content types
             AddType text/css              css.gz
             AddType text/calendar         ics.gz
             AddType text/javascript       js.gz
             AddType application/json      json.gz
             AddType text/html             html.gz
             AddType image/svg+xml         svg.gz

             # Serve correct content charset
             AddCharset utf-8 .css.gz \
                              .ics.gz \
                              .js.gz \
                              .json.gz
         </IfModule>

      # Force proxies to cache gzipped and non-gzipped files separately
      Header append Vary Accept-Encoding

     </FilesMatch>

     # Serve correct encoding type
     AddEncoding gzip .gz

 </IfModule>
...