Wordpress - pagespeed insights - Задайте правила эффективного использования кеша для статических объектов: различия между версиями

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2023
Перейти к:навигация, поиск
Строка 41: Строка 41:
 
  </IfModule>
 
  </IfModule>
 
  </FilesMatch>
 
  </FilesMatch>
 +
 +
 +
Другой вариант
 +
 +
<ifModule mod_headers.c>
 +
  <filesMatch "\.(ico|jpe?g|png|gif|swf|svg|webp|ttf|otf|woff|woff2|eot|sfnt)$">
 +
    Header set Cache-Control "max-age=25920000"
 +
  </filesMatch>
 +
  <filesMatch "\.(css)$">
 +
    Header set Cache-Control "max-age=25920000"
 +
  </filesMatch>
 +
  <filesMatch "\.(js)$">
 +
    Header set Cache-Control "max-age=25920000"
 +
  </filesMatch>
 +
</ifModule>
 +
 +
<IfModule mod_expires.c>
 +
ExpiresActive on
 +
ExpiresByType application/pdf A31557600
 +
ExpiresByType image/x-icon A31557600
 +
ExpiresByType image/vnd.microsoft.icon A31557600
 +
ExpiresByType image/svg+xml A31557600
 +
ExpiresByType image/jpg A31557600
 +
ExpiresByType image/jpeg A31557600
 +
ExpiresByType image/png A31557600
 +
ExpiresByType image/gif A31557600
 +
ExpiresByType image/webp A31557600
 +
ExpiresByType video/ogg A31557600
 +
ExpiresByType audio/ogg A31557600
 +
ExpiresByType video/mp4 A31557600
 +
ExpiresByType video/webm A31557600
 +
ExpiresByType text/css A31557600
 +
ExpiresByType text/javascript A31557600
 +
ExpiresByType application/javascript A31557600
 +
ExpiresByType application/x-javascript A31557600
 +
ExpiresByType application/x-font-ttf A31557600
 +
ExpiresByType application/x-font-woff A31557600
 +
ExpiresByType application/font-woff A31557600
 +
ExpiresByType application/font-woff2 "access 3 day"
 +
ExpiresByType application/vnd.ms-fontobject A31557600
 +
ExpiresByType font/ttf A31557600
 +
ExpiresByType font/otf A31557600
 +
ExpiresByType font/woff A31557600
 +
ExpiresByType font/woff2 "access 3 day"
 +
</IfModule>

Версия 08:39, 13 августа 2021

Доступная цена

Wordpress - pagespeed insights - Задайте правила эффективного использования кеша для статических объектов

Ошибка в сервисе https://developers.google.com/speed/pagespeed/insights/?hl=ru

Задайте правила эффективного использования кеша для статических объектов Найдено 39 ресурсов
Благодаря долгому времени хранения кеша страница может быстрее загружаться при повторных посещениях

Решение - это установить WP SUPER CACHE для Wordpress + добавить в .htaccess сайт строки:

<FilesMatch "\.(webm|ogg|mp4|ico|pdf|flv|jpg|jpeg|png|gif|webp|js|css|swf|x-html|css|xml|js|woff|woff2|otf|ttf|svg|eot)(\.gz)?$">
<IfModule mod_expires.c>
AddType application/font-woff2 .woff2
AddType application/x-font-opentype .otf
ExpiresActive On
ExpiresDefault A0
ExpiresByType video/webm "access plus 1 year"
ExpiresByType video/ogg "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/ico "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-truetype "access plus 1 year"
ExpiresByType application/pdf       "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
Header set Expires "max-age=A10368000, public"
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>
</FilesMatch>


Другой вариант

<ifModule mod_headers.c>
  <filesMatch "\.(ico|jpe?g|png|gif|swf|svg|webp|ttf|otf|woff|woff2|eot|sfnt)$">
    Header set Cache-Control "max-age=25920000"
  </filesMatch>
  <filesMatch "\.(css)$">
    Header set Cache-Control "max-age=25920000"
  </filesMatch>
  <filesMatch "\.(js)$">
    Header set Cache-Control "max-age=25920000"
  </filesMatch>
</ifModule>

<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A31557600
ExpiresByType image/x-icon A31557600
ExpiresByType image/vnd.microsoft.icon A31557600
ExpiresByType image/svg+xml A31557600
ExpiresByType image/jpg A31557600
ExpiresByType image/jpeg A31557600
ExpiresByType image/png A31557600
ExpiresByType image/gif A31557600
ExpiresByType image/webp A31557600
ExpiresByType video/ogg A31557600
ExpiresByType audio/ogg A31557600
ExpiresByType video/mp4 A31557600
ExpiresByType video/webm A31557600
ExpiresByType text/css A31557600
ExpiresByType text/javascript A31557600
ExpiresByType application/javascript A31557600
ExpiresByType application/x-javascript A31557600 
ExpiresByType application/x-font-ttf A31557600
ExpiresByType application/x-font-woff A31557600
ExpiresByType application/font-woff A31557600
ExpiresByType application/font-woff2 "access 3 day"
ExpiresByType application/vnd.ms-fontobject A31557600
ExpiresByType font/ttf A31557600
ExpiresByType font/otf A31557600
ExpiresByType font/woff A31557600
ExpiresByType font/woff2 "access 3 day"
</IfModule>