为什么后退按钮不适用于HTTP POST? [英] Why does the back button not work with HTTP POST?

查看:161
本文介绍了为什么后退按钮不适用于HTTP POST?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们使用HTTP POST提交页面时,我们无法使用浏览器后退按钮的原因是什么?但是HTTP GET没问题呢?我已经读过浏览器试图阻止多个POSTS(以避免对服务器进行多次更新),因为它无法区分浏览器上的BACK和RELOAD之间的区别?浏览器如何在BACK和RELOAD之间无法分辨?

What is the reason that we cannot use the browser Back button when we submit a page using HTTP POST? But it is fine with HTTP GET? I have read that the browser tries to prevent multiple POSTS (to avoid multiple updates to server) because it cannot tell the difference between BACK and RELOAD on the browser? How can browser not tell between BACK and RELOAD?

推荐答案

返回不是发送到服务器的特殊请求。返回只导航到上一页,就像刚刚在导航栏中输入网址并点击go一样。它与重载相同,与服务器的基本页面请求相同。他们都只是GET请求。

Back isn't a special request that goes to the server. Back just navigates to the previous page, same as if you just entered the url in the navigation bar and hit go. It's really the same thing as a reload which is the same as a basic page request from the server's point of view. They're all just GET requests.

当您回到使用帖子的页面时,它会重新发送帖子而不是获取。一般来说,浏览器已经内置了保护措施(你确定要回去吗?浏览器会重新发送以前提交的信息)。

When you hit back on a page that used a post, it resends a post rather than a get. Generally browsers have built in protections against that ("Are you sure you want to go back? Browser will resend previously submitted information").

它不重新加载的原因这样的帖子是因为,就像你说的那样,它不想重新发送用于将该页面发送到服务器的信息,因为它会发布一些内容,或者双重购买。

The reason it doesn't reload posts like that is because, like you said, it doesn't want to resend the information used to get that page to the server, because it'll double post something, or double buy something.

这篇关于为什么后退按钮不适用于HTTP POST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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