简体   繁体   English

JavaScript history.go和负载均衡器问题

[英]JavaScript history.go and load balancer question

I have a web application that I have recently place behind a load balancer. 我有一个最近放置在负载均衡器后面的Web应用程序。 There is a page that has the javascript:history.go(-1) method in a link. 有一个页面的链接中包含javascript:history.go(-1)方法。 The previous page is a form that performs a submit. 前一页是执行提交的表单。 When I click on the link that performs the go method, going to the server directly, does not try to resubmit the form. 当我单击执行go方法的链接时,直接转到服务器,不会尝试重新提交表单。 But when I click on the same link through the load balancer the form does a resubmit. 但是,当我通过负载均衡器单击同一链接时,该表单会重新提交。 Does anyone have any ideas on how to perform this task through a load balancer so the link does not resubmit the page? 是否有人对如何通过负载平衡器执行此任务有任何想法,以使该链接不会重新提交页面?

This behavior could be caused by not having "sticky sessions" enabled in the Load Balancer. 此行为可能是由于未在负载均衡器中启用“粘性会话”而引起的。 It wouldn't know the resulting page load from the go is coming from the same user, so instead of simply displaying the page, it's re-serving it. 它不知道从随后出现的页面加载go从同一个用户来了,所以,而不只是显示的页面,它是重新为它服务。

Do you know if it has "sticky sessions" enabled or if that's an option? 您知道它是否启用了“粘性会话”还是可以选择的?

If possible, use the Post/Redirect/Get pattern for the "previous" page. 如果可能,请对“上一页”页面使用“ 发布/重定向/获取”模式。 In other words - process the POST request and instead of returning a result redirect to another page. 换句话说-处理POST请求,而不是返回结果重定向到另一个页面。 It will be loaded using GET and the form won't be re-submitted upon navigating back to it. 它将使用GET加载,导航回该表单时不会重新提交该表单。

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

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