skip to Main Content

im building a new site and i’m trying to improve its speed and page rank. One of the problems i have is Leverage browser caching. I’ve read online different solutions, but none of them seems to work for me. I edited the .htaccess file and added the following code:

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

I still cannot fix the error. Also, Gtmetrix report shows that the problem is only with my front page images. (I’m using wordpress and front page is a static page).
Is there a way to add expiry header to specific files by location ?
Thanks in advance 🙂

2

Answers


  1. That codes works only in apache service.
    please inter your website address.
    for more information:
    https://gtmetrix.com/leverage-browser-caching.html
    https://developers.google.com/speed/docs/insights/LeverageBrowserCaching

    Login or Signup to reply.
  2. I have just resolved it. You have to enable mod_expires module. Have a look on my answer :- Leverage browser caching not working – Htaccess & mod_expires Active

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search