简体   繁体   English

外部http请求有害吗?

[英]are external http requests detrimental?

I'm using a service to generate code and i get responses back from an external service. 我正在使用服务生成代码,并且从外部服务获得响应。 I'm often getting 30+ at a time. 我经常一次超过30。

I'm also using a favicon service to fetch favicons. 我也在使用favicon服务来获取favicon。 The favicon service allows prefixing the domain with an arbitrary number to bypass the browser connection limit (eg. http://2245.example.com/?url=example.net ) favicon服务允许为域添加前缀任意数字,以绕过浏览器连接限制(例如http://2245.example.com/?url=example.net

In total my site can make upwards of 50-100 requests, but 15 of them are from my server I used yslow and got a big fat F for this. 总的来说,我的网站最多可以提出50-100个请求,但是其中15个来自我的服务器,我使用yslow并为此得到了一个很大的脂肪F。 Are these requests blocking? 这些请求是否被阻止? I could be generating 30 or more on a single page load, although it seems to load fine in testing... everything on my actual page loads immediately and I use css3 and jquery to fade in the animations nicely 我可能在单个页面加载时生成30个或更多,尽管在测试中似乎加载得很好...实际页面上的所有内容都立即加载,并且我使用css3和jquery很好地淡化了动画

There's a maximum of 4-6 concurrent requests in most browsers so the others will be delayed yes, but it depends on what they are as to whether or not they're blocking. 大多数浏览器中最多有4-6个并发请求,因此其他浏览器会被延迟,但是,这取决于它们是否阻塞。

You should avoid it - if it's part of your service consider loading the data in bulk on your server for the client via an AJAX call, that way you can also cache the results to avoid so many offsite requests. 您应该避免使用它-如果它是服务的一部分,请考虑通过AJAX调用将数据批量加载到客户端的服务器上,这样,您还可以缓存结果以避免这么多异地请求。

It'd help if you could show the page for more comprehensive advice, what're the codes for? 如果您可以显示页面以获得更全面的建议,这将有所帮助,代码是什么? Do they change? 他们会改变吗? Can you do it from your server rather than the client? 您可以从服务器而不是客户端执行此操作吗?

Browsers have a pipeline where a limited number of requests are simultaneously executed so there will be a bottleneck if your web page is loading 50-100+ images. 浏览器的管道可以同时执行有限数量的请求,因此,如果您的网页正在加载50-100个以上的图像,则会出现瓶颈。

The best way to get around this is to serve up image content as sprites. 解决此问题的最佳方法是将图像内容作为精灵。 This involves: 这涉及:

  • Getting your server to fetch the images on behalf of the web page. 让您的服务器代表网页获取图像。
  • Creating the corresponding sprites on the server side. 在服务器端创建相应的精灵。
  • Serving up the sprited images as well as the sprite decoding reference points to the web page from your server. 从服务器将sprited图像以及sprite解码参考点提供给网页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM