-1

Am building a site that makes a lot of requests for javascript and css files, and I've being reading about CDNs. I have a spare domain name and hosting space which I would like to use host these static files. My main domain is hosted on shared linux box with control panel. How do I go about setting the CDN

Scott Pack
  • 14,907
  • 10
  • 53
  • 83
MrFoh
  • 145
  • 2
  • 2
  • 10
  • Do you really mean a CDN? As in a global network of servers connected to key internet points? Or do you just want a cookieless domain? –  Nov 30 '11 at 11:52
  • @sam yes a cookieless domain – MrFoh Nov 30 '11 at 16:04

1 Answers1

2

You don't, unless your site scales beyond a point where you start to experience performance issues because it is overloaded.

The reason for this is simple: Having resources on a CDN requires the client's browser to start an additional session, complete with DNS lookup and everything, to download them. This usually costs performance.

Beyond that, a content delivery network basically is just a fancy name for a second (third, fourth...) server: Load your main site from http://example.com and reference the static content from http://cdn-example.com. On a large scale, there is obviously more to it, but that's the fundamental.

Something else: Having to load a lot of resource files is usually a sign of weak site design: Try to combine your resources into as few files as possible. It should usually be possible to condense all your JS and CSS in only a few files.

Sven
  • 98,649
  • 14
  • 180
  • 226
  • 4
    Browsers only open a certain number of connections per host. By having files spread (e.g. some on a CDN) will open more connections, thus loading the page faste. The DNS lookup is a small price worth paying. – Frands Hansen Nov 30 '11 at 11:51
  • And often-used resources (like jQuery) get cached a single time when many sites use the same CDN, this is another advantage – MichelZ May 22 '12 at 14:18