Jump to content

"Add an Expires or a Cache-Control Header"


GaVrA

Recommended Posts

I am fine tuning my forum, and iv been using YSlow to help me with that. One of the things where i got an F is "Add Expires headers" so i am wandering how hard could that be to fix it... :)

 

There is bunch of text here:

 

http://developer.yahoo.com/performance/rules.html#expires

 

but i dont understand how to implement this?

Link to comment
Share on other sites


A first-time visitor to your page will make several HTTP requests to download all your sites files, but using the Expires header you make those files cacheable. This avoids unnecessary HTTP requests on subsequent page views. Expires headers should be used on all components including scripts, stylesheets, and Flash components

 

If you see my tut about very good htaccess file in tutorials section here then the last part is all about expires.

 

http://www.invisionbyte.net/index.php?auto...;showarticle=65

 

extract from it

 

ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 120 minutes"
ExpiresByType image/jpeg "access plus 120 minutes"
ExpiresByType image/png "access plus 120 minutes"
ExpiresByType text/css "access plus 60 minutes"
ExpiresByType text/javascript "access plus 60 minutes"
ExpiresByType application/x-javascript "access plus 60 minutes"
ExpiresByType text/xml "access plus 1 seconds"

 

 

 

so basicly you use the visitors browsers cache for serving graphics and more.

example, i visit your site, with the instruction my browser downloads a lot of things to store in my browsers cache, for me the first page will be a little slow, but then everything speeds up, because all that is downloaded in my cache is served from my cache and not your site anymore.

benefits, you less bandwidth, me speedier website

you see in extract, that images like jpg and gif are stored in my browsers cache for more then 120 minutes.

rest is self explicatory.

 

I use this on my site, which is in my signature, so first load is a bit slow and then it speeds up for the reasons explained above.

http://www.xxx-devils.com/DevilsLair/4thBanner.jpg

Visit My TopList

Visit My Pagerank Toplist

Link to comment
Share on other sites


Uff i hate when i want to learn something new but i just dont have time for it... :D

 

Ok so based on ur tut and this:

 

http://developer.yahoo.com/performance/rules.html#expires

 

i now have .htaccess just like the one u posted in that tut but everything is on "access plus 10 years". Only text/html and text/xml is on "access plus 1 seconds". YSlow reported that i had hmm 76 components without a far-future expiration date and now there is only 13 of them... :)

 

Ok now i dont understand why it wont add "access plus 10 years" on javascript files and css file?

 

Also how can i add a far-future expiration date for favicon? :huh:

post-29-1242640386_thumb.png

Link to comment
Share on other sites


i think

 

 

 

Minify JS
This one required a little work. I installed YUI compressor and created a batch file. I also used this batch file to combine my javascript files into one file, before compressing it; and I used it to compress my main CSS files too.

http://www.xxx-devils.com/DevilsLair/4thBanner.jpg

Visit My TopList

Visit My Pagerank Toplist

Link to comment
Share on other sites


css and js remains a b*tch,

 

yslow wants a certain method applied but it is not possible to apply that method always, certain pages i can get on grade A and certain are lower.

I use manual compression on css and js

 

see http://www.cssdrive.com/index.php/main/csscompressor/

 

that makes my css very small, and altough yslow may not pick it up, i benefit anyways, same principle for js files

http://www.xxx-devils.com/DevilsLair/4thBanner.jpg

Visit My TopList

Visit My Pagerank Toplist

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.