Best way to allow and control cache
YSlow
I was testing some of my websites using Yahoo's YSlow and noticed the following comment:Specify an expiration at least one week in the future for the following resources
My .htacces file contains the following code:
ExpiresActive On
ExpiresDefault "access plus 1 day"
Is this the best way to do it? And Why does YSlow advice开发者_运维知识库 you to set the cache for at least one week?
Why does YSlow advice you to set the cache for at least one week?
Because they consider (and it's not a bad idea) that one day is not quite long enough : if you have some user that comes to your website only a couple of times per week, a cache of 1 day will not be useful for him.
Instead, the basic idea is to cache forever -- and to change the URL (changing the name of the file, typically) when a file is modified, to force the browse to download the new version.
精彩评论