Hosting images on separate sub domains

早过忘川 提交于 2019-11-28 21:32:13

A couple advantages to it:

  • A separate domain prevents your domain's cookies from being sent for every image request, where they're not needed. Reduces the bandwidth overhead for each request.
  • Most browsers will only make a certain number of HTTP requests at one time to a particular domain, so serving images and other static content off a second domain potentially doubles the number of HTTP requests at one time.
  • You can conceivably use a different, lighter weight webserver like nginx/lighttpd to serve the static content.

Downsides:

  • Managing it.
  • Two DNS lookups instead of one.

When a browser is requesting static files like CSS and Javascript, it often limits the number of connections to a given server/sub-domain. Putting static files under a different domain allows more simultaneous downloads.

If set up correctly, the different sub-domain may just be a directory on your webserver. Depends on your config-file-fu.

This is covered in a couple of the Stackoverflow podcasts.

One concern - if you are serving an https page the user may get a warning about a mix of secure and insecure items.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!