简体   繁体   English

防止Firefox页面状态缓存

[英]prevent firefox page state caching

How do i prevent firefox from caching page state? 如何防止Firefox缓存页面状态? I'm developing a web app and firefox is automatically setting previously checked checkboxes without triggering any events. 我正在开发一个Web应用程序,firefox会自动设置以前选中的复选框,而不会触发任何事件。 Is there a way to prevent firefox from doing this or do I just have to reset my entire ui on startup with js? 有没有一种方法可以防止firefox这样做,还是我只需要在使用js启动时重设整个ui?

You can add autocomplete="off" to the afflicted fields, MDN Document . 您可以将autocomplete="off"添加到受影响的字段MDN Document中 If that doesn't work and you can use jQuery I would go with $(form).reset() on page load as an easy fix. 如果这不起作用,并且您可以使用jQuery,则可以在页面加载时使用$(form).reset()作为简单的解决方法。

You'll probably need to set the HTTP Expires header to be expired, that way Firefox won't cache the page, it'll go back to the server. 您可能需要将HTTP Expires标头设置为过期,这样Firefox不会缓存该页面,它将返回服务器。

In PHP you can do this by calling: 在PHP中,您可以通过调用以下命令来执行此操作:

  header("Expires: 0");

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

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