使用greasemonkey清除缓存

发布于 2024-08-13 06:02:25 字数 172 浏览 2 评论 0原文

我有一个在信息亭中运行的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十级心震 2024-08-20 06:02:25

普通的 javascript 没有权限执行此操作,这显然是一个安全漏洞。

GM javascript也没有足够的权限。 Firefox 扩展以提升的权限运行,这就是该插件可以清除缓存的原因。

一些选项:

  1. 如果您制作自己的 Firefox 扩展,请从“ 开始清除缓存按钮'之一,它可能可以清除某种事件和/或计时器的缓存。

  2. JavaScript 可以重新加载页面,并指定不使用缓存:window.location.reload(true)

  3. 您可以设置一个 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:

  1. 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.

  2. JavaScript can reload the page, and specify that the cache not be used: window.location.reload(true).

  3. 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.

无法回应 2024-08-20 06:02:25

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文