302重定向加载空白页面。

huangapple go评论118阅读模式
英文:

302 redirect loads blank page

问题

我们对一些模拟器页面实现了基于Spring的“异步”响应的HTTP 302重定向。一旦浏览器接收到重定向响应,就会加载空白页面。然而,如果我手动加载重定向地址(与模拟器相同的URL,不带参数),页面会正确加载。

然而,这是关键:

在最新版本的Chrome中,我得到一个空白页面,如果我手动加载地址(刷新不起作用),页面会正常加载。

在更新的Firefox(78.0.2)中,我的旧页面仍然显示在屏幕上,而不是空白页面。手动加载/重复操作正常工作。

在旧版的Firefox(76.0)中,一切都如预期地工作,重定向在第一次就有效。

这让我想知道问题是否出在浏览器缓存上。因此,我根据MDN上的说明将“cache-control: no-cache”添加到我的响应中,但问题仍然存在。

对于问题可能出在哪里,有什么建议吗?

英文:

We have an HTTP 302 redirect for some of our simulator pages as an async response implemented in Spring.
As soon as the redirect response is received in the browser, blank page loads. However, if I load the redirect address manually (same URL as simulator, without parameters) the page loads properly.

However, this is the kicker:

In latest Chrome, I get blank page, and if I manually load the address (refresh doesn't work), it loads fine.

In newer Firefox (78.0.2), my old page stays on screen, instead of blank page. Manual loading/repeating action works fine.

In older Firefox, (76.0), everything works as expected, and redirect works in first go.

This makes me wonder if the issue is with Browser caching. So I added "cache-control : no-cache" as mentioned on MDN to my responses, but the problem remains.

Any suggestions on where the issue might be?

答案1

得分: 1

最近我在处理重定向时,我们的一个应用出现了类似的情况。在浏览器(Chrome)中手动输入网址时完全正常,但在应用中作为重定向使用时却无法正常工作。
对我而言起作用的是将状态代码设置为302,而不是200。
可能几率不大,但也许这能解决问题。

我使用302状态码,新意图是"Found",而不是"Moved Temporarily"。
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

英文:

I recently had a similar situation with one of our apps when performing redirects. Same exact thing with the url working when manually entered into the browser (Chrome) but would not work when used as a redirect with the application.
What worked for me was setting the status code to 302 instead of 200.
Probably a long shot but maybe this will solve the issue.

I'm using 302 with the newer intent of "Found" instead of "Moved Temporarily."
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

huangapple
  • 本文由 发表于 2020年8月18日 13:23:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63462325.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定