Caching of images and javascripts

Joined: 11/28/2008

Hi folks

I have not really understood the best way to ensure caching of images and javascripts for a site, so that subsequent page loading of graphics takes place from the browser cache.

I had a php header which did not seem to be helping at all. Then I tried the trick to stop image flicker in IE6, in my htaccess file:
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/png A2592000

and find that this gives instant appearance of images on subsequent pages in both IE and FF.

My impression from the loading indicator on the browser is that any page is reloading all javascripts each time - as far as I can guess from the fact that the loading indicator is still green even after all visible page content is showing.

I always thought that a browser would normally cache all javascripts and style sheets too so that it never needed to reload them, but that doesn't seem to be happening for javascripts. Is there any php header or htaccess code which will make this happen?

Blessings and thanks

Tony

Online outreach:
Internet Evangelism Day
Helping church websites:
Church Websites

G&G Podcast Host
Matt Farina's picture
Joined: 06/01/2006
yslow

If you want to see what's being cached and what's being loaded try firebug and yslow. They can help you out.

And, for more info on expires headers see http://developer.yahoo.com/performance/rules.html#...

Matt Farina
Geeks and God Former Co-Host
www.mattfarina.com

Joined: 11/28/2008
Great, thanks! Tony

Great, thanks!

Tony

Online outreach:
Internet Evangelism Day
Helping church websites:
Church Websites