For what reasons do sites provide logic to switch betwe开发者_StackOverflow社区en http/https protocols for JavaScript include files? Why not always use https?
HTTPS means :
- You need a server configured properly
- You need a certificate on your server
- And, to not get a warning in the browser, you need a certificate signed by some trusted authority
- And this costs a bit of money
- A small bit of performance impact
- The server has to crypt the data
- The client has to de-crypt it
- I would bet HTTPS means less caching
- Maybe on the client side ?
- And, most probably, on proxies ?
If you don't need HTTPS... Well, why use it ?
There's less overhead if you just use http to serve the javascript include files. However, if you are running a site over https then you'll want to load everything over https, including the javascript include files.
Because you can get the page both with and without SSL.
If you mix secure and unsecure requests in a page, the user will get a warning, so when the page is requested using https, it will have to requests the scripts using https also. This is usually done automatically when you request scripts from the same site with a relative URL, but if you have to use a complete URL to request a script from a different domain, the protocol has to be set dynamically.
精彩评论