Why use protocol relative URLs?

What are protocol relative URLs?

Normal URLs look like:

Both of these URLs define the protocol that will be used.

Protocol relative URLs look like this:

Dropping the protocol from the URL allows the browser to assign the current protocol to the URL.

Why use protocol relative URLs?

CSS Example:

Protocol Relative CSS
/*Import Google Font*/
@import url(//fonts.googleapis.com/css?family=Open+Sans:300,400);

That will automatically use what the site is being called as, regardless if it is http or https.

NON-Protocol Relative
/*Import Google Font*/
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400);

Rather than state https: or https:, just leave it off on includes.

If your website is on our CDN all requests are served by the CDN.

If you are browsing the site in HTTPS mode, and another user is browsing the same pages in HTTP mode, two versions of those pages will be stored in the CDN cache, as the links are different between the two modes.

This splits your cache, which makes it less efficient.


Keywords: ssl

About the author

Level 1 Support

Level 1 Technical Support