Why do CDN web addresses not specify protocol?

Asked

Viewed 132 times

11

Usually web addresses start with http:// or https://, but CDN addresses like jQuery and Bootstrap start with //.

Example:

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

and

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

What does that mean?

1 answer

12


This indicates the browser to use the same protocol in the address bar of the page making the request.

Does that mean that:

  • if you are on a page served via HTTP, the request will be made to HTTP CDN

  • if you are on a page served through HTTPS, the request will be made to CDN HTTPS

Example

Suppose I have a website on www.meusite.com.br, and in it I place a reference equal to the one you indicated:

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

On IIS, I configure to allow my page to be served by both HTTP and HTTPS.

When the user accesses http://www.meusite.com.br, the browser will fetch javascript in http://code.jquery.com/jquery-1.11.0.min.js.

When the user accesses https://www.meusite.com.br, the browser will fetch javascript in https://code.jquery.com/jquery-1.11.0.min.js.

  • 8

    That is, this has nothing to do with CDN, you can use the same technique on any responsive site both at http and https.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.