cancel
Showing results for 
Search instead for 
Did you mean: 

Leverage browser caching

SOLVED

Leverage browser caching

Hi,

 

I have sen this posted on here before but I'm still having trouble with it. I've pasted the following code into my .htaccess file:

 

<IfModule mod_expires.c>

# Enable expirations
ExpiresActive On

# Default directive
ExpiresDefault "access plus 1 month"

</IfModule>

## 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 am still getting a message telling me to leverage browser caching whenever I run a page speed test.

Any ideas what I'm doing wrong?

 

Many thanks,

M&S

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Leverage browser caching

Hi M&S,

 

check the details - most likely there are some tracking or live chat scripts loaded from other servers listed there. your .htaccess can enable browser caching only for files loaded from your server.

hope this helps.

 

Anton Pachkine @ magento2.hosting : Magento Small Business Package.

View solution in original post

Re: Leverage browser caching

I agree with @Finestshops

 

Make sure you check the details in PageSpeed and you will most likely see that all the resources listed are hosted externally and there's nothing you can do about them. 

 

Unless your server isn't configured correctly, all your own contents should already be leveraging browser caching. 

View solution in original post

5 REPLIES 5

Re: Leverage browser caching

Hi M&S,

 

check the details - most likely there are some tracking or live chat scripts loaded from other servers listed there. your .htaccess can enable browser caching only for files loaded from your server.

hope this helps.

 

Anton Pachkine @ magento2.hosting : Magento Small Business Package.

Re: Leverage browser caching

I agree with @Finestshops

 

Make sure you check the details in PageSpeed and you will most likely see that all the resources listed are hosted externally and there's nothing you can do about them. 

 

Unless your server isn't configured correctly, all your own contents should already be leveraging browser caching. 

Re: Leverage browser caching

You have to enable 'enable mod_expires'. Type this command and restart apache server:

sudo a2enmod expires
Enabling module expires.
Run '/etc/init.d/apache2 restart' to activate new configuration!

Re: Leverage browser caching

Nice. This solved my problem.

Re: Leverage browser caching

Thanks this helped me too