`title: Cache Storage 条目统计与定期清理策略``categories: Web 开发/前端/数据管理``keywords: Cache Storage,统计,清理,Service Worker,容量``description: 统计 Cache Storage 条目与大体积资源,设计定期清理与容量控制策略,保障缓存健康与命中率。`统计与清理async function auditCache(name = 'dynamic') { const c = await caches.open(name); const keys = await c.keys(); let total = 0; for (const k of keys) { const r = await c.match(k); const b = await r.clone().arrayBuffer(); total += b.byteLength; } return { count: keys.length, total }; }

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部
2.714647s