views:

33

answers:

1

I want to know how long certain files like css, html and js are desirable to be cached by .htaccess setting and why different time setting for each file type?

In few examples i saw that someone cache html for 10 mins, js for a month and imagery for a year.

+1  A: 

I think it depends how often a resource is updated. You HTML content is probably dynamic, so you can't cache it for a long time. Otherwise a visitor sees the changes after a long delay.

On the other side, pictures are rarely updated, so you can set longer cache time.

The JavaScript files are often updated for new features or bugfixes. Maybe you can use a version number for this files (core.js?v=12323) so that you can change the number in your HTML content to get them refreshed by a visitor. This way you can cache them for a longer time as well.

aeby