JQuery / javascript caching issue

I was wondering - when using jQuery (or any other javascript include) on my network, does the browser cache it after the first load for all pages (I assume that it is) or will it load it every time?

2nd, when the user leaves the browser and starts it again (to download my site), will the jquery js file be saved or will it be fully downloaded again?

THX

+7
javascript jquery
source share
5 answers

It depends on the browser and how your server is configured. Look at the headers sent by the server along with the file (you can use a tool like Firebug to view the headers). It is a good idea to use a jQuery file hosted by Google, as many other sites (including stackoverflow) use the same file. Then the browser can cache this file and never download it from your server. This page contains a list of files hosted by google, and this page explains how to properly configure your server before (tell your browser) cache files.

+9
source share
  • Yes, scripts will be cached between pageviews, as well as CSS files and images.

  • Anyway. Typically, the cache is maintained between browser restarts.

+3
source share

1: Yes, the browser caches all jscript / css includes

2: If the user does not clear his cache. Yes, it will still be in the browser cache, even after closing and reopening.

+3
source share

If your web server is serving jquery.js using the appropriate expires header, then yes, the browser will cache it.

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

+3
source share

As a rule, it will not be reloaded, but if your server does not explicitly tell the browser to cache it for a while, it will send a request for each page load with the request β€œhas jquery.js been updated?”. which is almost as slow as just loading it again.

You can check how it works on your site using Google Page Speed ​​or Yahoo YSlow .

+2
source share

All Articles