.htaccess mod_deflate не работает с js?ver и css?ver

Я проверил несколько тем и погуглил в поисках решения. Но я не могу сжать js?ver=X и css?ver=X. Также по какой-то странной причине .svgs из определенной папки также отображаются, в то время как .svgs из других папок сжимаются.

Вот мой .htaccess. Судя по всему, что я читал до сих пор, все должно быть в порядке. Сжатие также работает с любыми другими файлами, кроме файлов с расширением ?ver и некоторых .svg.

    # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

<IfModule mod_expires.c>
AddType application/vnd.ms-fontobject .eot 
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
ExpiresActive On
ExpiresByType text/html "access plus 500 seconds"
ExpiresByType image/gif "access plus 14 days"
ExpiresByType image/ico "access plus 14 days"
ExpiresByType image/jpeg "access plus 14 days"
ExpiresByType image/jpg "access plus 14 days"
ExpiresByType image/png "access plus 14 days"
ExpiresByType text/css "access plus 14 days"
ExpiresByType text/javascript "access plus 14 days"
ExpiresByType application/x-javascript "access plus 14 days"
ExpiresByType application/javascript "access plus 14 days"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 14 days"
</IfModule>

Вот некоторые из «Включить сжатие gzip», которые я получаю от GTMetrix или PageSpeed ​​Insights:

Compressing /wp-content/themes/Avada/assets/min/js/general/avada-header.js?ver=5.1.6 could save 25.0KiB (87% reduction).
Compressing /wp-content/themes/Avada/assets/css/style.min.css?ver=5.1.6 could save 132.7KiB (83% reduction).
Compressing /wp-content/themes/Avada-Child/images/icon-w-adresse.svg could save 494B (44% reduction).

Wordpress 4.7.5 + Тема: Avada 5.1.6


person phr4pp    schedule 01.06.2017    source источник
comment
ОБНОВЛЕНИЕ: я попробовал следующий код в файле functions.php: // remove wp version param from any enqueued scripts function vc_remove_wp_ver_css_js( $src ) { if ( strpos( $src, 'ver=' ) ) $src = remove_query_arg( 'ver', $src ); return $src; } add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 ); add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 ); Он удалил часть ?ver=X в моих результатах GTMetrix/PageSpeed, но они все еще отображаются. Может ли причина этого быть в чем-то другом?   -  person phr4pp    schedule 01.06.2017
comment
Проверьте заголовки Content-Type, которые возвращаются с несжатыми ресурсами. Есть ли разница с аналогичными ресурсами, которые сжимаются?   -  person DocRoot    schedule 01.06.2017
comment
Я ничего не заметил. Вот веб-сайт: klinger-tecnoseal.com   -  person phr4pp    schedule 02.06.2017
comment
Похоже, проблема не в строке запроса... может быть, в расположении файлов - любых других .htaccess файлах? Например, http://www.klinger-tecnoseal.com/wp-content/themes/Avada/assets/min/js/general/avada-elastic-slider.js?ver=5.1.6 кажется сжатым, а http://www.klinger-tecnoseal.com/wp-content/plugins/fusion-core/js/min/avada-fusion-slider.js?ver=1 — нет?   -  person DocRoot    schedule 02.06.2017
comment
Это странная вещь, которую я не могу понять... Я не нашел никаких других файлов htaccess, кроме одного в корневой папке.   -  person phr4pp    schedule 06.06.2017


Ответы (1)


Загадка разгадана: по какой-то причине сервер Nginx, в отличие от другого сервера, который является Apache ... оба с одного хоста. Настройки Nginx были скорректированы и теперь все работает нормально.

person phr4pp    schedule 13.06.2017