为什么不总是使用HTTP发布进行Ajax调用? [英] Why not always use HTTP post for ajax calls?

查看:80
本文介绍了为什么不总是使用HTTP发布进行Ajax调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道HTTP get和post方法之间的区别(如

I know the differences between HTTP get and post methods (as expalined in big details in this question).
My question is why not always use the post method for AJAX calls, which is safe. Is there get request faster? is there is reason to prefer get then post?

对于没有ajax调用,有一个原因-共享指向相同URL的链接,但是对于AJAX,此参数不好...

For none ajax call there is a reason - to share a link to the same url, but for AJAX this argument it's not good...

推荐答案

GET请求更小,更快;并在客户端以及可能正在使用的任何代理服务器中利用缓存.

GET requests are smaller and faster; and leverage caching, both on the client side and on the part of any proxies that may be in play.

对于那些预计不会经常更改的数据,GET请求通常非常明智,因为除非有必要,否则它们更有可能不被重新发送.

For data that isn't expected to change very often, GET requests are often very sensible, as they have a greater chance of not being resent unless necessary.

但是,对于预期会更频繁更改的数据,POST确实是更安全的选择,因为它将始终重新发送到服务器,并确保始终尊重更改.

For data that is expected to change more often, however, POST is indeed the safer option, as it will always be resent to the server, making sure that changes are always respected.

还有一些语义问题在起作用. POST请求实际上仅应在旨在修改服务器上的数据时使用.

There is also semantic issues that come into play. POST requests should really only be used when the intent is to modify data on the server.

这篇关于为什么不总是使用HTTP发布进行Ajax调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆