Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does CDN know which website the client is visiting when fetching jquery.min.js or other resource from CDN?

Tags:

javascript

cdn

Can CDN create some kind of statistics by tracking visitors of my site or they download needed libraries without sharing the URL of the page they visit ?

like image 344
knm Avatar asked Jun 09 '15 22:06

knm


People also ask

Should I use CDN for jQuery?

1: jQuery CDN is Simple to Use The jQuery CDN is popular among web developers because it is simple to use and understand. Because the jQuery download file employs open coding standards and simple syntax, developers do not have to spend much time implementing it on their site or application.

What are the advantages of using CDN in jQuery?

When you use jQuery CDN then you are actually doing 2 positive things: Decreasing the load on your website since the jQuery file will load from a CDN and not from your website. jQuery loads faster from CDNs than from your website.

What is the purpose for including jQuery lib from a content delivery network?

Why should I use a CDN to host jQuery? The jQuery library download time will be reduced. Your users in Europe will hit the CDN in Europe and your users in the US should hit the US CDN. As a result, this will reduce your overall page load time.


1 Answers

Yes, they know the URL of the page which requested the resource (e.g. by looking at the Referer header). So they could track what websites requested a certain resource. The only exception is when an HTTPS page requests a resource over a non-secure connection. In that case the Referer won't be set, but the Origin header could be of some help anyway.

Tracking individual users could certainly be done, but it's impractical for a number of reasons:

  1. CDN resources are meant to be heavily cached by browsers, so they will be requested and downloaded once for many different page views, making "passive" stats bogus.

  2. Forcing the user to download the resource for each page visited makes CDNs pointless, slows down the navigation for no reason and overloads CDN's bandwidth. This was the technique used by long-dead views counters on GeoCities pages from the 90s (sigh).

  3. Tracking users requires setting an identifying cookie at least. This adds complexity to the web service (since it can't be a simple file server anymore) and latency to the response time, since the UID has to be looked up in some form of DB or newly generated. Etags could be abused as well, with the same issues of cookies.

  4. As an alternative, using query string parameters could work, but requires collaboration from the target page, which has to include the UID as a parameter to each request, which means URLs cannot be hard-coded. I guess this is not the case you are talking about.

To sum up, a CDN could track your visitors, but the downsides of doing so are actually larger than the hypothetical gain, assuming the performance and the linked profitability is the main goal of running a CDN. If analytics are more valuable than performance or economy of operation, like it could be for a free CDN, then one could sacrifice performance for gaining insights by applying points 2 and 3.

At that point, one would have to demonstrate the soundness of collected stats in order to be able to sell them for any marketing purpose. Besides, the nature of the files usually served by CDNs make them quite uninteresting. For instance, I don't see a lot of profitability in knowing how many people use a certain version of jQuery out there.

like image 69
Stefano Sanfilippo Avatar answered Sep 22 '22 13:09

Stefano Sanfilippo