Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I know that http caching and sending 304 response is to save some bandwidth and of course some load time.

However in my web site there are about 40 css stylesheet files and 20 javascript files (don't ask me why)

I know that would be a great idea to combine most of them into one and reduce HTTP requests.

However my question is. Is there actually a way of caching when browser wouldn't even make requests for certain resources for some time? Because making requests and even getting 304 response is still some work.

share|improve this question

2 Answers 2

Yes, read this detailed article/video: https://developers.google.com/speed/articles/caching

share|improve this answer

The best way is to set a max-age directive in the cache-control header. Specifically:

Cache-control: public,max-age=2592000

2592000 is the number of seconds you wish the file to be cached for (in this example it is 30 days ie 60x60x24x30).

Do note however, that many users visit websites with empty caches, so downloading all those files in the first place is a massive overhead. You should cut those down to at most 2 JS and 2 CSS files.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.