在空闲数小时后保持 ajax 网页正常运行
我有一个单页网络应用程序,因此没有页面刷新。有时我会让页面打开一夜,然后早上回来并再次开始与其交互。通常我发现我必须刷新。 Javascript 执行不正确 - 就地编辑加载奇怪的数据,ajax 调用不触发...这与后端无关,似乎只是浏览器转储了内存,或者其他什么。不涉及任何会话。
Google 日历如何保持打开状态 3 天并仍然发出事件警报?
我有一个每 5 秒触发一次的“保持活动”调用,试图让浏览器保持警惕,但它没有帮助。有什么窍门呢?有没有办法告诉浏览器将所有内容永远保留在内存中?
(我确信网络上的许多地方都解决了这个问题,但我不知道要搜索什么。)
I have a one page web app so there is no page refreshing. Sometimes I leave the page open overnight and I come back in the morning and start interacting with it again. Usually I find I have to refresh. Javascript performs incorrectly - edit-in-place loads weird data, ajax calls don't fire... It's nothing to do with the backend, it seems to just be the browser dumping it's memory, or something. There're no sessions involved.
How does Google calendar stay open for 3 days and still fire event alerts?
I have a 'keep alive' call that fires every 5 seconds, in an attempt to keep the browser on its toes, but it hasn't helped. What's the trick? IS there a way to tell the browser to hold everything in memory forever?
(I'm sure this is addressed in numerous places on the web, but I can't figure out what to search for.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能需要注意的事项:
祝你好运!
Possible things to look at:
Good luck!
当您刷新页面时,是否由于会话超时或其他原因而需要进行任何身份验证?因为如果您真正需要做的就是按 F5 就可以了,我建议您在应用程序中创建一个“空闲”计时器,如果没有交互(IOW 重置),每小时执行一次 window.reload()每次有互动时的计时器)
希望这有帮助
When you refresh the page do you need to do any authentication because of a timed-out session or anything ? Because if all you really need to do is hit F5 and you're good to go, I would suggest you create an 'idle' timer in your app that does a window.reload() every hour if there is no interaction (IOW reset that timer each time there is an interaction)
Hope this helps