Resolvendo o Leverage browser cache sem plugin

Se você usou o Google PageSpeed ou o GTmatrix para testar o seu site, é possível que estas ferramentas tenham sugerido que você otimizasse o cache do navegador (Leverage browser cache).

Para resolver isto em servidores Apache, adicione o código abaixo no .htaccess que fica na raiz do seu WordPress.

# Browser cache #
ExpiresActive On
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
# Browser cache #
# Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
# Cache-Control Headers#
# Turn ETags Off
FileETag None
# END Turn ETags Off

Simples assim. Limpe o cache se usar algum tipo de plugin para isso e faça o teste novamente.

Dica lá do TechNumero

Deixe um comentário