中止 HTTP 请求。服务器端优势?

发布于 2024-12-05 13:38:23 字数 205 浏览 1 评论 0原文

例如,在 JavaScript AJAX 库中,可以中止 AJAX 请求。这是否有任何服务器端优势,或者只是为了客户端清洁?它是 TCP 的一部分吗?

例如,如果我通过 AJAX 从我的 JavaScript Web 应用程序请求基于 Python 的服务器服务(这是资源密集型)并中止此 AJAX 请求,中止是否有可能减轻负载在服务器上,或者我的ajax库会忽略服务器的响应吗?

In, for example, JavaScript AJAX libraries it is possible to abort an AJAX request. Is there any server side advantage to this or is it just for client-side cleanliness? Is it part of TCP?

If, for example, I am requesting via AJAX a Python based server service – which is resource intensive – from my JavaScript Web App and abort this AJAX request, is it possible that aborting will ease the load on the server, or will the my ajax library just ignore the response from the server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无语# 2024-12-12 13:38:23

如果您使用框架abort功能,它不会影响服务器端。不管怎样,服务器仍然会处理该请求。

It does not affect the server-side if you use your frameworks abort feature. The server will still process the request regardless.

完美的未来在梦里 2024-12-12 13:38:23

一旦你向服务器上的资源 URL 发出 HTTP 请求(无论是否异步,又名 ajax 或“常规”),你就无法从客户端/使用另一个 http 请求中止它(除非你的服务有一些奇怪的侦听器)等待潜在的后续 http 请求并停止接收请求)。我的建议是,如果您有一项资源和耗时的操作,要么将其拆分为更简单的操作,将其并行化,要么至少做出一些定期响应,至少通知用户它仍在工作并且尚未死亡

Once you made an HTTP request to a resource URL on your server (be it Asynch or not, aka ajax or "regular"), you can't abort it from your client / with another http request (unless your service has some weird listener that awaits for potential consequent http requests and stops itself up receiving one). My proposition, if you have one resource and time consuming operation, either split it into simpler operations, parallelize it or at east make some periodic responses to at least inform the user that it's still working and hasn't died

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文