What's faster for including scripts, using CDN (Google) or storing them locally in website's root?

前端 未结 7 1358
眼角桃花
眼角桃花 2020-12-02 14:55

What\'s faster for including scripts, using CDN (Google) or storing them locally in website\'s root?

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 15:19

    I'd say Google's CDN for reasons others have stated.

    However, if your target market is in close proximity to your server it may be better to server it from your server.

    Say, for instance, you have a site forOrlandoFloridaPeopleOnly.com/. If your server is hosted in Orlando, Florida and Google's closest content delivery servers are in Miami, Florida and Atlanta, Georgia (which is true), your server may [will probably] be faster if the visitor didn't already have a cached copy of the file from Google CDN.

    Remember, if you do serve static content to your visitors form your server try to parallelize the downloads by utilizing sub-domains or other means. And for goodness sakes...don't transfer cookies for static content.

    I'm not sure how reliable this source is: Google data centers. So don't necessarily count on it.

提交回复
热议问题