如何清理内存缓存中的铬? [英] How to clean chrome in-memory cache?

查看:169
本文介绍了如何清理内存缓存中的铬?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Chrome中的扩展程序,并且每次用户在Google中搜索时都会尝试执行操作。目前,我正在使用 chrome.webRequest onBeforeRequest侦听器。它适用于绝大多数情况,但某些请求是通过缓存完成的,不会执行任何调用。我在API文档中找到了关于缓存的内容:

I'm developing an extension in chrome and I'm trying to perform an action each time a user searches in Google. Currently I'm using chrome.webRequest onBeforeRequest listener. It works perfectly most of the cases but some of the requests are done through the cache and doesn't perform any call. I've found this in the API documentation about caching:


Chrome采用两个缓存 - 磁盘缓存和非常快速的内存缓存。内存中缓存的生命周期与渲染进程的生命周期相关,该进程大致对应于一个制表符。来自内存缓存的应答请求对Web请求API不可见。如果请求处理程序更改其行为(例如,阻止请求的行为),则简单页面刷新可能不会遵守此更改的行为。为确保行为更改通过,请调用 handlerBehaviorChanged()以刷新内存中的缓存。但不要经常这样做;刷新缓存是一项非常昂贵的操作。注册或取消注册事件侦听器后,您无需调用 handlerBehaviorChanged()

Chrome employs two caches — an on-disk cache and a very fast in-memory cache. The lifetime of an in-memory cache is attached to the lifetime of a render process, which roughly corresponds to a tab. Requests that are answered from the in-memory cache are invisible to the web request API. If a request handler changes its behavior (for example, the behavior according to which requests are blocked), a simple page refresh might not respect this changed behavior. To make sure the behavior change goes through, call handlerBehaviorChanged() to flush the in-memory cache. But don't do it often; flushing the cache is a very expensive operation. You don't need to call handlerBehaviorChanged() after registering or unregistering an event listener.

我尝试过使用handlerBehaviorChanged()方法清空内存中的缓存,但没有任何区别。尽管不建议我甚至在每次请求后都尝试调用它。

I've tried using the handlerBehaviorChanged() method to empty the in-memory cache, but there was no difference. Although it's not recommended I've even tried to call it after every request.

这是我的代码:

chrome.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES = 1000;
chrome.webRequest.onBeforeRequest.addListener(function (details) {
    //perform action
    chrome.webRequest.handlerBehaviorChanged();
} {
    urls: ["*://*.google.com/*"]
});

有没有办法从扩展中清空/禁用内存缓存?

Is there any way to empty/disable this in-memory cache from the extension?

推荐答案

I asume 缓存由谷歌网站用Object,Arrays, ...所以清空Memory-Cache中的浏览器将无济于事。

I asume the "Caching" is performed by the Google-Website with some crazy JavaScript in Objects, Arrays,... so emptying the browser in Memory-Cache won't help.

我首先想到的是数据存储在sessionStorage中(由于值中包含搜索项[在这里我搜索了测试],并在每次请求/更改所选搜索词时更新/创建。

My first thought was that the data was Stored in the sessionStorage (due to the fact that the Values had the search-term in them [here I searched for test] and are updated/created on every request/change of the selected "search-word"

我尝试清除会话存储(甚至是期刊),但它并没有真正改变不的加载,而且存储被重新创建,甚至没有存储,显示出不同的结果。

由于这些信息以及我可以'检查了几千行JavaScript代码,我只能假设网站做了缓存请求。我希望这些信息能够指引您正确的方向。

Due to this Information and the fact that I can't check several 1000 lines of minfied JavaScript Code, I just can asume that the website does the caching of the requests. I hope this Information can point you in the right direction.

这篇关于如何清理内存缓存中的铬?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆