Kevin Katzke
Kevin Katzke

Reputation: 3761

Speedtest High priority: Enable Browser caching

I'm using Magento 1.7 and i have recently switched my shop to a new Cloud Computing Hoster. To check my shops performance I run several pagespeed test. And every result gave me the same High priority: Enable Browser caching!

So far I have activated every single cache at System -> Cache. So I don't know why my shop does not make use of Browser Caching.

By switching to the new Hoster I deleted the files stored in the /var directory. This was mentioned in a short Tutorial for switching a Magento Shop to a server.

Does anyone know how to solve this problem?

Thanks!

Upvotes: 1

Views: 12723

Answers (2)

Copy and paste at the end of .htaccess file to improve laverage browser caching.

enter image description here

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

Upvotes: 3

Fiasco Labs
Fiasco Labs

Reputation: 6457

This recommendation has nothing to do with Magento's caching.

There are browser cache directives that can be sent to tell the client's browser how long to keep page objects like images, media content, page html, stylesheets, javascripts, etc in the local client browser cache before trying to refresh. These directives are enabled through DSO modules (apache web server), server configuration and .htaccess file entries.

The .htaccess file installed by Magento has the following section which is only activated if your web server is loading the mod_expires DSO Module

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

    ExpiresActive On
    ExpiresDefault "access plus 1 year"

</IfModule>

More information from Yahoo on setting Expires directives

ADDED

How to tell what modules are being loaded. This only works if the php interpreter is being run through loading the mod_php5 DSO module in Apache. Create a phpinfo() configuration dump page and look for the following:

enter image description here

Once the expires module is working and paying attention to your .htaccess entries, you can use an addon like LiveHttpHeaders in Firefox to view the HTTP server request/response headers similar to as follows:

enter image description here

Upvotes: 9

Related Questions