Zen Cart Logo
Forums / Basic Configuration / Enable browser caching of static assets

Enable browser caching of static assets

Locked

Views: 6,228

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
16 Jan 2010, 6:47 PM
#1
yd29999 avatar

yd29999

Zen Follower

Join Date:
Jan 2006
Posts:
120
Plugin Contributions:
0

Enable browser caching of static assets

Hello,
We are running 1.3.8a.
I did a speed test this morning and one thing it showed in "Enable browser caching of static assets" was "FAILED (No max-age or expires)'
I've been looking n looking. Can someone point me in the right direction or tell me how to fix it?

Thanks in advance.

16 Jan 2010, 8:48 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Enable browser caching of static assets

Enable browser caching
You can not control a users browser settings

16 Jan 2010, 8:55 PM
#3
absolute avatar

absolute

Totally Zenned

Join Date:
May 2005
Location:
Bath, Somerset
Posts:
1,054
Plugin Contributions:
2

Re: Enable browser caching of static assets

You want to send a default "cached time" to your users browsers though, to say "this image/javacript file etc" won't change for the next x hours. For this, on an Apache server, you can use mod_expires. DON'T do this if you regularly change image files. My advice would be to place an htaccess file in your root directory, and then just add the mod_expires to certain file extenstions. OBVIOUSLY DON'T add .php or .html or .htm to the mod_expires, otherwise the browser will never refresh your page.

Details on mod_expires can be found here.

Absolute

16 Jan 2010, 8:59 PM
#4
yd29999 avatar

yd29999

Zen Follower

Join Date:
Jan 2006
Posts:
120
Plugin Contributions:
0

Re: Enable browser caching of static assets

Thank you Absolute for the info and sound advice. I'll try it later.
Thanks again !

10 Apr 2010, 9:16 PM
#5
mrspiffy avatar

mrspiffy

New Zenner

Join Date:
Mar 2009
Posts:
29
Plugin Contributions:
1

Re: Enable browser caching of static assets

Here's a sample .htaccess file:

ExpiresActive On
ExpiresDefault "access plus 15 days"
ExpiresByType image/gif "access plus 15 days"
ExpiresByType image/png "access plus 15 days"
ExpiresByType image/jpg "access plus 15 days"
ExpiresByType text/css "access plus 15 days"
ExpiresByType text/html "access plus 15 days"

adding this to my site made a big difference.