Chrome为什么不缓存我的动态表单字段?(Why doesn't Chrome cache my dynamic form field?)

系统教程 行业动态 更新时间:2024-06-14 16:57:39
Chrome为什么不缓存我的动态表单字段?(Why doesn't Chrome cache my dynamic form field?)

我在Symfony2中遵循Post / Redirect / Pattern的简单表单。 该表单包含一个id文本字段,该字段在控制器中随机值动态填充。

我注意到Chrome中存在一些奇怪的行为 - 如果用户提交表单然后再次点击, id字段包含一个全新的值。 如果我编辑这个ID然后重复这个过程,那么这个值被缓存,所以看起来Chrome似乎只是在它看到这个值已经改变时才会缓存它。

Firefox或Safari中不会发生此问题。 有没有什么方法让Chrome执行相同的方式? 在这个问题的答案说,问题在于使用隐藏字段,但由于我只是使用标准文本字段,所以我很茫然。

I'm following the Post/Redirect/Pattern for a simple form in Symfony2. This form contains an id text field, which is dynamically populated in the controller with a random value.

I've noticed some odd behaviour in Chrome - if the user submits the form and then clicks back, the id field contains a brand new value. If I edit this id and then repeat the process, the value does get cached, so it looks like Chrome only bothers caching it if it sees that the value has changed.

This behaviour doesn't occur in Firefox or Safari. Is there any way to get Chrome to perform the same way? An answer in this question says that the issue lies with using a hidden field, but as I'm just using a standard text field I'm at a loss.

最满意答案

据我所知,没有标准规定这里​​应该发生什么。 所以你不能真正依赖浏览器的行为。

因此,如果对用户来说非常重要的是当用户按下后退按钮时它应该是新的id,那么使用一些客户端脚本来实现它。 无论使用什么浏览器。

As far as I know there is no standards that specify what should happen here. So you can't really rely on the browsers behavior.

So, if it is really important for you that it should be new id when the users press the back-button, then make it happen with some client side script. No matter what browser is being used.

更多推荐

本文发布于:2023-04-13 11:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/41dd23f549583c737a69e293c988b52f.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   表单   缓存   动态   Chrome

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!