`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 }; }

发表评论 取消回复