gpt4 book ai didi

google-chrome - 有人可以解释一下 Google Chrome 内存缓存吗?

转载 作者:行者123 更新时间:2023-12-02 12:22:44 25 4
gpt4 key购买 nike

根据this API 文档,这是我找到的唯一描述内存缓存的来源:

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.

我需要更好地了解内存缓存。具体来说,我需要 Chrome 在每次访问网站时生成完整的 webRequest/资源瀑布,包括刷新页面。显然,如果使用内存缓存,则情况不可能如此。

当我创建新选项卡时,内存缓存是否会为新选项卡重新清理?

“非常昂贵的操作”在数量上意味着什么?

如果我每次在同一选项卡中重新加载页面时都调用 handlerBehaviorChanged() ,这会保证完整的瀑布流吗?在这种情况下,10 分钟内 20 次的限制似乎相当低。

非常感谢任何帮助,谢谢!

最佳答案

就您的情况而言,我认为您的问题在于长期缓存而不是内存缓存。在资源瀑布中,多个请求可以标记为已缓存。如果您愿意,可以通过多种方式来避免这种情况:

请记住仅将这些规则应用于您真正需要的资源。否则,您的网络服务器将因不必要的请求而过载。

如文档中所述:内存缓存不适用于不同的页面渲染,即使对于相同的 url 和同一选项卡(内存缓存附加到渲染进程的生命周期),所以我认为这不适用于您的情况。每次显示页面时,渲染周期都会结束,如果再次渲染,则会开始另一个周期。例如:当第一次加载图像时出现在瀑布中,但同一页面上的后续请求则不会出现。

关于google-chrome - 有人可以解释一下 Google Chrome 内存缓存吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35514369/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com