使用greasemonkey清除缓存
我有一个在信息亭中运行的 Web 应用程序,该应用程序是使用 Greasemonkey 设置的,以便我们可以自定义有关应用程序的一些小内容,并确保自定义仅发生在信息亭中。我一直在研究 GM api,希望它有一些影响浏览器设置的功能,但可惜它看起来只影响浏览器中运行的页面。当应用程序中发生某个事件时,有没有办法告诉浏览器清除缓存?
I have a web application running in a kiosk, which is set up with greasemonkey so that we can customize little things about the application and ensure the customizations only occur at the kiosk. I have been digging through the GM api hoping that it would have some functionality to affect browser settings, but alas it looks like it only affects pages running in the browser. Is there a way for me to tell the browser to clear it's cache when a certain event happens in the application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
普通的 javascript 没有权限执行此操作,这显然是一个安全漏洞。
GM javascript也没有足够的权限。 Firefox 扩展以提升的权限运行,这就是该插件可以清除缓存的原因。
一些选项:
如果您制作自己的 Firefox 扩展,请从“ 开始清除缓存按钮'之一,它可能可以清除某种事件和/或计时器的缓存。
JavaScript 可以重新加载页面,并指定不使用缓存:
window.location.reload(true)
。您可以设置一个 cron 作业或 Windows 计划任务来终止 firefox 任务,每天运行一次,例如 CCleaner,然后重新启动 Firefox。
无论如何,这可能是个好主意,因为如果运行时间太长,Firefox 往往会陷入困境并占用内存。
同样,您可能会考虑重新启动整个计算机并在每次重新启动时进行清理。
Ordinary javascript does not have permission to do this, it apparently would be a security hole.
GM javascript also does not have sufficient privileges. Firefox extensions operate with elevated privileges, which is why that add-on can clear the cache.
Some options:
If you make your own Firefox extension, starting with that 'Clear Cache Button' one, it can probably clear the cache on some kind of events and/or timer.
JavaScript can reload the page, and specify that the cache not be used:
window.location.reload(true)
.You can set up a cron job, or Windows Scheduled Task, to kill the firefox task, once per day, run something like CCleaner, then restart Firefox.
This is probably a good idea anyway, as Firefox tends to bog down and hog memory, if left running too long.
Similarly, you might consider restarting the whole computer and cleaning up on every restart.
您可以查看“清除缓存按钮”- Firefox-Addon.
下载(而不是安装)扩展程序,将其解压(使用 7zip、WinRar、WinZip、WinAce 等)并查看 onclick 执行的代码。
Greasemonkey 脚本应该同样有效。
如果您只是复制粘贴他的解决方案,请不要忘记向原作者添加注释!
〜克里斯
You might have a look at the 'Clear Cache Button' - Firefox-Addon.
Download (not install) the extension, extract it (with 7zip, WinRar, WinZip, WinAce, ...) and have a look at the code executed onclick.
The same should work as Greasemonkey Script.
Don't forget to add a note to the originaly author if you just copy-paste his solution!
~Chris