Настройка Cache-Control + mod_expires в .htaccess, но использование кэша браузера все еще не работает - PullRequest
0 голосов
/ 09 апреля 2020

Я хорошо настроил файл .htaccess, но не смог заставить работать кеш Leveraged Browser Cache. GTMetrix сообщает, что для нескольких изображений .png и .svg не задан срок действия. 1. Expires_module включен и работает в Apache 2. Установите Cache-Control и Enable Browser Cache, которые установлены в .htaccess. Код .htaccess находится ниже. Любой совет, чтобы сделать работу кеширования браузера приветствуется : -)

#Set Cache-Control
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|svg|js|css|swf)$">
Header set Cache-Control "max-age=84600, public"
#End Cache-Control
</FilesMatch>
#Enable browser cache
<IfModule mod_expires.c>
  ExpiresActive On

  # Images
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"

  # Video
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType video/mpeg "access plus 1 year"

  # CSS, JavaScript
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"

  # Others
  ExpiresByType application/pdf "access plus 1 month"
  ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
#End browser cache
#Enable HSTS
...