Mobile app version of vmapp.org
Login or Join
Yeniel560

: Make browsers not to make HTTP requests for cached items 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

@Yeniel560

Posted in: #Cache #CacheControl #Optimization

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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Yeniel560

2 Comments

Sorted by latest first Latest Oldest Best

 

@Cofer257

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme