Hacker News: Double-keyed caching: Browser cache partitioning

Source URL: https://addyosmani.com/blog/double-keyed-caching/
Source: Hacker News
Title: Double-keyed caching: Browser cache partitioning

Feedly Summary: Comments

AI Summary and Description: Yes

**Summary:** The text discusses the transition from traditional web caching models to Double-keyed Caching due to privacy concerns. This change fundamentally alters resource retrieval and storage in browsers, impacting performance and impacting web architecture strategies. The adoption of this new model emphasizes the trade-off between privacy and performance, particularly regarding cross-site tracking.

**Detailed Description:**

The text provides a comprehensive examination of the evolution of web caching mechanisms, particularly focusing on the shift to Double-keyed Caching as a privacy measure. Here are the major points discussed:

– **Traditional Caching Model (Pre-2020):**
– Browsers previously utilized a simple key-value store for cached resources, allowing resources shared by multiple sites to be cached once, improving load times and reducing bandwidth.
– Key advantages included:
– Reduced bandwidth usage through resource sharing
– Enhanced performance for users visiting multiple sites with shared resources
– Cost savings on hosting due to public CDN leverage
– Quicker page loads through effective cache hits

– **Privacy Issues with Traditional Model:**
– This caching model led to various vulnerabilities:
– **Cache Probing:** Allowed one site to check if a user’s data from another site was cached.
– **Timing Attacks:** Enabled measuring load times to ascertain cache statuses.
– **Cross-site Tracking:** Cached resources acted as persistent identifiers for users.

– **Introduction of Double-Keyed Caching:**
– The new model combines two cache keys: the top-level site and the resource URL.
– This partitioning ensures that resources are cached separately for each site, preventing cross-site tracking while introducing a necessity for additional storage:
– Example of cache structure:
“`json
{
“topLevelSite”: “site-a.com”,
“resource”: “https://cdn.example.com/jquery-3.6.0.min.js”
}
“`

– **Performance Impact:**
– The change leads to a notable increase in cache misses and network resource loads:
– 3.6% increase in cache miss rate
– 4% increase in bytes loaded from the network
– 0.3% effect on First Contentful Paint (FCP)
– Although these statistics may seem minimal, their effect varies based on how resources are utilized.

– **Network Bandwidth Implications:**
– Increased cache miss rates mean greater bandwidth usage, particularly affecting:
– Shared Libraries (e.g., jQuery)
– Web Fonts (e.g., Google Fonts)
– Large resources (e.g., machine learning models)
– Illustrated with examples, enterprises may experience significantly increased total cache usage due to the necessity of duplicate downloads across domains.

– **Adaptation Strategies Required:**
– Organizations need to revisit their CDN strategies, with a potential shift toward self-hosting to optimize bandwidth use.
– A revised domain strategy could lead to consolidation for performance enhancement.
– Recommended changes include:
– Domain consolidation rather than separate asset hosts
– Self-hosting critical resources instead of caching from CDNs
– Architectural updates to align bundle boundaries with domain structures

– **Long-term Planning and Recommendations:**
– There was recognition of the continuing evolution of web platforms and the importance of careful monitoring and adaptation of design strategies concerning cache partitioning.
– Consider discussion on optimizing the loading of well-known resources, particularly larger client-side AI models, alongside improvements in model management.

This shift towards privacy-respecting caching models emphasizes the need for ongoing adaptation in web architecture to balance user privacy with performance needs, presenting challenges but also opportunities for innovation in resource management and delivery strategies in web development.