1

I'm not finding a definite answer on the web.

Lets say we have two sites both pull jquery from the same CDN.

  • pageOne.com > mycdn.com/jquery

  • pageTwo.org > mycdn.com/jquery

Now

  1. I go to pageOne.com.
  2. jquery is downloaded from mycdn.com/jquery.
  3. I go to pageTwo.org (on second tab)

Question: Is jquery downloaded again for pageTwo.org (its the same CDN and the same jquery js file), or can I use the browser cache for pageTwo.org? (i have already downloaded it when I was on pageOne.com before)

flowb
  • 30
  • 10
Andre Elrico
  • 10,956
  • 6
  • 50
  • 69

2 Answers2

4

The single cached version is used for both sites. The URL for the jQuery library stays the same. It doesn't matter what references it.

This is one of the main benefits of using a common CDN for common libraries... the fact that the user will probably have cached it already from some other site.

Brad
  • 159,648
  • 54
  • 349
  • 530
2

Decentraleyes extension for Firefox and Chrome let you use the same cached file across all the visited sites... it caches the ressources files (JS mainly) to serve them from the local storage copy.

Otherwise this QA (requesting same file from two different origins) may be helpful in this situation.

And yes for chrome the cached files are served cross main different domains because the js file location (URL) is the same.

Links: caching behavior, cross origin requests, cross domain cache. different-origin disk cache version, caching with CORS

flowb
  • 30
  • 10