html - Google Chrome 预渲染中的 "cookie conflict"

标签 html google-chrome prefetch prerender

我一直在使用 Chrome 的预渲染功能

<link rel="prerender" href="/path" />

但是在最近的更新之后,当我尝试使用 [chrome://net-internals/#prerender] 进行调试时。它表明预呈现由于 “Cookie 冲突” 而中止。

我尝试调试以确保某些 ajax 调用在页面加载后是否正在更改 cookie,但没有找到。预渲染仍然中止。它过去可以与以前的 chrome 版本一起正常工作。

最佳答案

您看到的是 cookie 冲突造成的。

示例:

假设 a.com 使用 cookie greeting=... 来指示用户希望收到的问候语。
假设问候语设置为“你好”。 我们prerender a.com/a.html,呈现“greeting=hello”。当服务器生成 a.html 时,它将从正在预呈现的网页上的 cookie 发出“hello”

现在,在显示预呈现之前,假设 a.com 上的某个其他页面将问候语更新为“greeting=howdy” 接下来,假设用户导航到 a.com/a.html。预呈现器将被换入。但是,它看到的“问候”cookie 的版本与现在的值不同。因此,页面仍然显示“你好”,而不是(更新后的)“你好”。

在内部,它跟踪所有 cookie 在预呈现期间公开(在 HTTP header 或 javascript 中)。如果在显示预渲染之前修改了其中任何一个,它会使预渲染无效。

这种失效是您观察到的。

关于html - Google Chrome 预渲染中的 "cookie conflict",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26247142/

相关文章:

javascript - Es 6模块已在Chrome中加载但未运行

具有不同高度的 CSS Floating Div 与它们之间的空间对齐

html - 页面在 Chrome 中快速重新格式化自己

css - 除非清除缓存,否则谷歌浏览器 css 不会更新

c++ - 如何搭建应用层预取系统

c - 学习在 Intel/AMD 64 位上用 C 语言预取缓冲区的最佳资源

django - 使用 prefetch_lated(model_SET).all() 获取相关模型外键(除了 ManyToMany 之外)

jquery - 位置固定的顶部导航栏在 Firefox 中表现异常

html - Bootstrap 中的列在带有 float : none 的 Firefox 中没有响应

javascript - Chrome 文件链接过长 - 选项卡崩溃