We are planning a web packaging R&D track that involves three main technologies: Prefetch, Signed Exchanges, and FatPack. We also want to incorporate telemetry instrumentation to evaluate their performance and behavior.
Steps:
-
Understand the technologies:
- Prefetch: A way to fetch resources in advance (e.g., ) to improve performance for future navigations.
- Signed Exchanges (SXG): A web standard that allows a publisher to sign a resource (like an HTML page) so that a cache (e.g., a CDN) can serve it with the publisher's signature, enabling features like privacy-preserving prefetching and faster loads.
- FatPack: A concept (possibly from AMP) where multiple resources (like images, scripts) are packaged together into a single file to reduce request overhead. We might be referring to a specific implementation or a general idea of bundling.
-
Goals of the R&D track:
- Evaluate the performance benefits of each technology in real-world scenarios.
- Understand the integration challenges (e.g., server support, browser support, caching).
- Measure the impact on user experience (e.g., page load times, resource loading).
- Collect telemetry to validate hypotheses and guide future development.
-
Telemetry instrumentation:
- We need to define what metrics to collect and how to collect them.
- Possible metrics:
- Network metrics: request count, transferred bytes, timing (DNS, TCP, TLS, request/response, etc.).
- Page load metrics: First Contentful Paint (FCP), Largest Contentful Paint (LCP), Time to Interactive (TTI), etc.
- Resource-specific metrics: for prefetched resources, were they used? For SXG, was the exchange validated? For FatPack, how many resources were in the pack and how were they used?
- Error rates: failed prefetches, invalid SXG signatures, FatPack unpacking errors.
-
Experiment design:
- We can set up A/B tests or controlled experiments where we enable/disable these features for a subset of users.
- For each technology, we need a way to conditionally serve the optimized version.
-
Implementation steps:
a. Prefetch:
- Add prefetch hints for critical resources (e.g., next page resources, above-the-fold images) in the HTML.
- Instrument: use the Resource Timing API to track when prefetched resources are actually used (e.g., when they are requested by the page). Also, track if prefetched resources are used within a certain time (to avoid wasting bandwidth).
- Compare with a control group without prefetch.
b. Signed Exchanges:
- Generate SXG for HTML pages (and possibly other resources) on the server. This requires setting up a signing key and including the appropriate headers (Format: application/signed-exchange; ...).
- The server must serve the SXG with the correct content type and also provide the certificate chain (or a way to validate) for the exchange.
- Browser support: Currently, Chrome supports SXG. We might need to check the user agent and conditionally serve SXG.
- Instrument: track if the page was loaded as an SXG (via the navigator.connection or other means? Actually, we can look at the response headers and the Signed-Exchange header in the request). Also, measure the performance of SXG loads vs non-SXG.
- We can also test the prefetching of SXG (using the prefetch link with the appropriate as and signature?).
c. FatPack:
- This is less standardized. We might consider a few approaches:
* Bundle multiple resources (e.g., images, CSS, JS) into a single file (like a tar or a custom format) and then unpack on the client.
* Alternatively, use HTTP/2 multiplexing and see if bundling is still beneficial? Or use a service worker to intercept and bundle?
- We need to define a clear FatPack format and a way to unpack (maybe a script that runs early in the page).
- Instrument: track the bundle size, the number of resources in the bundle, and the time to unpack. Also, compare the number of requests and bytes transferred with and without FatPack.
-
Telemetry collection:
- We can use an existing analytics solution (like Google Analytics, or a custom event tracker) to send events and metrics.
- We must be cautious about privacy and performance impact of telemetry.
- Use the PerformanceObserver API to collect performance metrics and send them to our backend.
-
Analysis plan:
- Compare key metrics (FCP, LCP, TTI, total bytes, request count) between the test group (with the technology) and control group.
- Segment by network conditions (e.g., fast 4G, slow 3G) and device types (mobile, desktop).
- Check for regressions (e.g., does prefetch cause wasted bandwidth?).
-
Rollout plan:
- Start with a small percentage of users (e.g., 1%) for each technology and gradually increase if metrics are positive.
-
Challenges and risks:
- Browser support: SXG is only in Chrome (and maybe Edge). Prefetch is widely supported but behavior may vary. FatPack requires custom client-side code.
- Complexity: Implementing and maintaining three different experiments simultaneously might be challenging. Consider running them sequentially or in a way that they don't interfere.
- Cache invalidation: For SXG, the signature is tied to the certificate and the resource URL. If the resource changes, the signature must be updated. Also, the validity period of the SXG is limited (usually 24 hours). We need to handle that in the experiment.
-
Documentation and sharing:
- Document the experiment setup, results, and conclusions for each technology.
Given the complexity, we might break the R&D track into phases:
Phase 1: Prefetch
- Implement prefetch for next page resources.
- Instrument and compare.
Phase 2: Signed Exchanges
- Set up SXG for HTML pages.
- Instrument and compare.
Phase 3: FatPack
- Define a FatPack format (e.g., a JSON manifest with base64 encoded resources? or a binary format?).
- Implement a packer (server-side) and unpacker (client-side).
- Instrument and compare.
However, note that FatPack might be more experimental and less standard. We might need to research existing solutions (like AMP's bundle) and decide on an approach.
Alternatively, we could run all three in parallel but on non-overlapping user segments to avoid interference.
Let's outline a plan for each:
Prefetch:
-
How to implement:
- In the HTML of page A, add and for other resources (images, scripts) that are likely needed on page B.
- We can also use the
SpeculationRules API (if available) to do more speculative loading.
-
Instrumentation:
-
Use performance.getEntriesByType('resource') to see which resources were prefetched and when they were used (by checking if they were requested again when needed). However, note that a prefetched resource might be stored in the cache and then used without a network request, so we might not see a new request. Therefore, we can also check the initiatorType of the resource when it's used (if it's used because of a prefetch, it might not have an initiator). Alternatively, we can set a custom attribute on the prefetched link and then when the resource is requested (if it is) we can check the initiator? Not straightforward.
-
Another idea: use the prefetch event in the Service Worker? But we are not necessarily using a service worker.
-
We can use the Resource Timing API's nextHopProtocol to see if the resource was fetched from cache (if prefetched) or network? But that doesn't tell us if it was prefetched.
-
Actually, the browser doesn't expose a direct way to know if a resource was prefetched. We can try to infer by:
- Checking if the resource was requested during the prefetch phase (we can see the prefetch requests in the resource timing with
initiatorType of "prefetch"). Then, when the resource is used (if it is), we can see if it was fetched from cache (so no new request) or if it was requested again (which would be a waste). But if it's used from cache, we don't see a new request.
-
We can also use the prefetch link's onload and onerror events to track when the prefetch completes and whether it was successful.
-
So, for each prefetch link, we can record:
- The href, as, and other attributes.
- Whether the prefetch succeeded (onload) or failed (onerror).
- Then, during the page load (of the next page, if applicable), we can check the resource timing to see if the same resource was requested (and from where). But note: the next page might be a different window, so we have to coordinate across pages? That's complex.
-
Alternatively, we can do the experiment on a single page and prefetch resources that are used on the same page (like above-the-fold images that are in the viewport but not immediately requested because they are lazy-loaded). Then we can see if the lazy-loaded images load faster because they were prefetched.
Signed Exchanges:
-
How to implement:
-
We need to generate SXG for our HTML pages. This requires:
- Having a certificate for the domain (which we do).
- Using a tool to create the exchange (e.g.,
brotli and openssl or a library). The exchange includes the response headers and body, and is signed with the private key.
- The server must serve the SXG with the content type
application/signed-exchange;v=b3 and also provide the certificate chain in the Signature header? Actually, the signature is included in the exchange itself, but the browser needs to validate the certificate chain. The server must also serve the certificate at /.well-known/sxg/? There are details.
-
Alternatively, we can use a CDN that supports SXG (like Cloudflare) to generate and serve SXG.
-
We must also serve the original HTML for browsers that don't support SXG. We can use the Accept header to conditionally serve SXG or HTML.
-
We can also use the Vary: Accept header to cache separately.
-
Instrumentation:
-
We can check the navigator.connection? Not directly. Instead, we can look at the response headers in the page. If the page was loaded as an SXG, the Content-Type would be application/signed-exchange. But note: the browser will convert the SXG into a normal response and then the page will see the original URL. So, from the page's JavaScript, we cannot directly know if it came from an SXG.
-
However, we can set a custom header in the original HTML (that we only send when we are not serving SXG) and then check for its absence? But if the SXG is validated, the browser will use the original response headers (from the exchange). So if we set a header in the original HTML, it will be present in the SXG too.
-
Alternatively, we can use the Signed-Exchange header in the request (if the browser sends one). But that's not available in the page.
-
We might need to rely on server logs to see which requests were served as SXG (by the Accept header). Then, we can correlate with performance metrics that are sent from the client (which include a user ID or session ID?).
-
We can assign users to groups (SXG on/off) and then compare the performance metrics between groups.
-
We can also use the PerformanceNavigationTiming entry to see the nextHopProtocol (if it's h3 or etc.) but that doesn't tell us about SXG.
FatPack:
-
How to implement:
-
Define a FatPack format. For example, we can create a JSON file that maps resource URLs to base64 encoded data. Then, we can have a script that runs early and replaces the original resource requests with the data from the FatPack.
-
Steps:
- On the server, for a set of resources (e.g., all images, CSS, JS that are needed for the initial page), create a FatPack file (say,
fatpack.json).
- In the HTML, instead of linking to the individual resources, we load a small script that reads the FatPack and then creates the necessary tags (img, link, script) with the data from the FatPack (using data URIs or blobs).
-
Alternatively, we can use a service worker to intercept requests and serve from the FatPack.
-
We must be cautious about the size of the FatPack: if we bundle too much, the initial HTML might become heavy. We can inline the FatPack in the HTML? Or make it a separate file and prefetch it.
-
We can experiment with different bundle sizes and compositions.
-
Instrumentation:
-
Challenges:
- The unpacking script might block rendering. We need to make it asynchronous.
- The FatPack might become stale if resources change. We need a versioning strategy.
- Browser support: using data URIs for large resources might have limitations (URL length, memory).
-
Overall experiment management:
We need a way to assign users to groups and persist the assignment across page views (so that we don't switch the user's experience in the middle of a session). We can use a cookie or localStorage.
We also need to ensure that the telemetry is sent reliably and with enough context (which group the user is in, which experiment variation, etc.).
-
Example of a simple telemetry event:
function sendTelemetry(eventName, data) {
// Use navigator.sendBeacon or an image request to send the data.
const payload = JSON.stringify({
event: eventName,
data: data,
timestamp: Date.now(),
userId: getUserId(), // from cookie or generated
experiment: 'prefetch', // or 'sxg', 'fatpack'
variation: 'test' // or 'control'
});
navigator.sendBeacon('/telemetry', payload);
}
-
Metrics to collect for each experiment:
For Prefetch:
- Prefetch initiated (time, URL)
- Prefetch completed (time, success/failure, size)
- Next page navigation: time from click to next page load event (and key metrics on next page)
- Whether the prefetched resource was used (if same page, we can check if the resource was requested from cache? but note: the resource might be used without a request if it's in the cache and we set the
src to the same URL).
For SXG:
- Server-side: log the
Accept header and the response (SXG or HTML).
- Client-side: we cannot directly detect SXG, so we rely on server logs and then compare the performance metrics of users who received SXG (from server logs) and those who didn't. But note: the assignment to SXG group must be random and we must have a way to link the client-side metrics to the server-side group. We can use a user ID that is set in a cookie by the server when it assigns the group.
Alternatively, we can conditionally set a JavaScript variable in the HTML (only when we are not serving SXG) and then check for its presence? But if we serve SXG, the browser will use the original HTML (which we can control) and we can set a variable in that HTML. However, note that the SXG must be exactly the same as the original HTML (except for the signature and headers). So we cannot change the HTML content for SXG vs non-SXG? Actually, we can have two different HTML responses? But that would break the signature because the exchange is a signed representation of the response. So the HTML must be the same.
Therefore, we cannot put a variable in the HTML that is different for SXG and non-SXG. So we have to rely on server-side assignment and then use a user ID that is set in a cookie (which is the same regardless of SXG) and then on the server we know which group the user is in by the cookie? But the cookie might be set after the first request. We can set the cookie on the first request and then use it for subsequent requests.
Given the complexity, we might also consider using existing frameworks or services that implement these technologies (e.g., for SXG, Cloudflare; for FatPack, maybe AMP's approach) to reduce development time.
Let me know if you need more details on any specific part.
I'll help you design a comprehensive R&D track for evaluating web packaging technologies with robust telemetry. Here's a structured plan:
R&D Track: Web Packaging Technologies Evaluation
1. Track Overview & Goals
Primary Objectives:
- Quantify real-world performance impact of Prefetch, SXG, and FatPack
- Understand adoption barriers and implementation complexities
- Build production-ready telemetry to validate hypotheses
- Develop governance model for technology adoption
Success Metrics:
- Core Web Vitals improvement thresholds
- Bandwidth reduction percentages
- Cache hit ratio improvements
- Implementation complexity scores
2. Phase-by-Phase Approach
Phase 1: Foundation & Telemetry Infrastructure (Weeks 1-4)
Deliverables:
-
Telemetry Schema Design
// Example telemetry event structure
{
"experiment_id": "sxg_eval_v1",
"variant": "treatment",
"metrics": {
"navigation_type": "navigate", // navigate, reload, back_forward
"prefetch_utilization": 0.65, // % of prefetched resources used
"sxg_validated": true,
"fatpack_unpack_time_ms": 42,
"cache_hit_ratio": 0.78,
"network_errors": ["sxg_signature_invalid"]
},
"context": {
"connection": "4g",
"device": "mobile",
"browser": "chrome_120"
}
}
-
Instrumentation Stack
- Client-side: PerformanceObserver API, Resource Timing, Navigation Timing
- Server-side: Nginx/Envoy module for SXG generation & validation logging
- CDN integration: Cloudflare Workers/Fastly Compute@Edge for experimental routing
- Storage: BigQuery/ClickHouse for high-cardinality analytics
-
A/B Testing Framework
- User cohort assignment (5% traffic for initial experiments)
- Feature flagging system (LaunchDarkly/Flagsmith)
- Statistical significance calculator (with Bayesian priors for early stopping)
Phase 2: Technology-Specific Evaluation
A. Prefetch Deep Dive (Weeks 5-8)
Research Questions:
- What's the optimal prefetch heuristic (viewport-based, navigation-predictive, ML-driven)?
- How does prefetch interact with HTTP/3 and connection coalescing?
- What are the privacy implications (e.g., prefetch fingerprinting)?
Experiments:
# Config matrix
experiments:
- name: "prefetch_strategy"
variants:
- "link_rel_prefetch"
- "speculation_rules_api"
- "no_prefetch"
- name: "prefetch_trigger"
variants:
- "hover"
- "visible_viewport"
- "30s_idle"
- name: "resource_type"
variants:
- "navigation_targets_only"
- "critical_resources"
- "all_outbound_links"
Key Measurements:
prefetch_hit_rate (prefetched → actually used)
bandwidth_waste_ratio (prefetched but never used)
navigation_time_delta (with/without prefetch)
cache_displacement_impact (prefetch evicting useful resources)
B. Signed Exchanges (SXG) Evaluation (Weeks 9-12)
Research Questions:
- What's the SXG validation overhead in real-world conditions?
- How does SXG interact with AMP and other packaged formats?
- What are certificate rotation and key management operational costs?
Implementation Plan:
Server Setup:
├── SXG Generator (brotli + sign)
│ ├── Key rotation automation (90-day certs)
│ ├── Fallback for non-compatible UAs
│ └── Vary: Accept header management
├── Validation Monitoring
│ ├── Invalid signature tracking
│ ├── Expired exchange detection
│ └── Certificate chain verification logs
Measurements:
// SXG-specific metrics
{
"sxg": {
"validated": true,
"validation_time_ms": 8,
"fallback_reason": null, // "unsupported_ua", "invalid_signature", etc.
"certificate_remaining_days": 83,
"exchange_size_bytes": 15420,
"compression_ratio": 0.67
}
}
C. FatPack Evaluation (Weeks 13-16)
Approach Options to Compare:
- Bundle-based: Webpack/Rollup single bundle
- Archive-based: tar/zip with manifest
- Binary format: Custom
.fatpack with delta updates
- Service Worker orchestration: Dynamic bundling
Evaluation Framework:
# Pseudocode for FatPack analyzer
def evaluate_fatpack(bundle):
metrics = {
'time_to_first_byte': measure_ttfb(bundle),
'parse_time': measure_js_execution(unpack_script),
'memory_overhead': measure_heap(unpacking),
'cache_efficiency': simulate_cache_behavior(bundle),
'update_cost': measure_delta_apply(bundle_v2)
}
return metrics
Key Questions:
- What bundle size threshold provides diminishing returns?
- How does FatPack affect debugging/production parity?
- Source map support and error reporting impact?
3. Telemetry Instrumentation Design
Core Metrics Dashboard
┌─────────────────────────────────────────────┐
│ Web Packaging Evaluation Dashboard │
├─────────────────────────────────────────────┤
│ Overall: │
│ • 15.2% faster LCP (SXG treatment) │
│ • 22% bandwidth reduction (FatPack) │
│ • 78% prefetch utilization rate │
├─────────────────────────────────────────────┤
│ Technology Comparison: │
│ ┌─────────┬─────────┬─────────┬─────────┐│
│ │ Metric │ Prefetch│ SXG │ FatPack ││
│ ├─────────┼─────────┼─────────┼─────────┤│
│ │ LCP Δ │ -8% │ -15.2% │ -5% ││
│ │ FCP Δ │ -6% │ -12% │ -3% ││
│ │ Bytes │ +12%* │ -18% │ -22% ││
│ │ Errors │ 0.2% │ 1.7% │ 0.8% ││
│ └─────────┴─────────┴─────────┴─────────┘│
│ * Prefetch bandwidth overhead │
└─────────────────────────────────────────────┘
Data Collection Strategy
- Sample Rate: 100% for SXG (critical), 10% for Prefetch/FatPack
- Retention: 90 days aggregated, 30 days raw
- Privacy: No PII, aggregated by country/device/connection
- Sampling Bias Control: Stratified sampling by:
- Network quality (effective connection type)
- Device tier (low-end vs high-end)
- Geography (for CDN edge cases)
4. Experiment Execution Plan
Traffic Allocation Strategy
Month 1:
Baseline collection (no experiments) → 20% traffic
Prefetch A/B test → 10% (5% control, 5% treatment)
Month 2:
SXG rollout (Chrome only) → 15% (5% control, 10% treatment)
Month 3:
FatPack pilot → 5% traffic (complex tech)
Combined SXG+Prefetch → 5% traffic
Rollback Criteria
- Core Web Vitals regression > 5% for any metric
- Error rate increase > 0.5%
- Telemetry pipeline failure > 30 minutes
- CDN cache hit ratio drop > 10%
5. Analysis & Reporting
Weekly Report Structure
## Week [X] Web Packaging Report
### Highlights
- ✅ SXG validation success rate: 99.2% (↑0.3% WoW)
- ⚠️ Prefetch waste rate: 18% (↑2% - investigate)
- 📈 FatPack adoption: 3.4% of eligible users
### Deep Dive: SXG Certificate Issues
Top failure reasons:
- Expired certificate (42%)
- Invalid signature (31%)
- Missing chain (18%)
- Unsupported algorithm (9%)
**Action Items:**
- [ ] Automate certificate rotation monitoring
- [ ] Alert on signature validation failures
### Next Week Focus
- Increase FatPack bundle size threshold from 100KB → 150KB
- Test SXG with Brotli vs Zstd compression
Quarterly Review Questions
- Which technology provides best cost-benefit ratio?
- What's the minimum viable implementation for production?
- Which edge cases require special handling? (e.g., authenticated content, dynamic HTML)
- How do these technologies complement or conflict with each other?
6. Risk Mitigation
| Risk | Probability | Impact | Mitigation |
|---|
| SXG breaks non-Chrome browsers | Medium | High | UA detection + graceful fallback |
| Prefetch wastes mobile data | High | Medium | Data-saver mode respect, user opt-out |
| FatPack debugging nightmare | High | High | Source map strategy, dev mode toggle |
| CDN compatibility issues | Medium | High | Multi-vendor testing (Cloudflare, Fastly, Akamai) |
| Legal/regulatory concerns (SXG trust) | Low | High | Legal review, transparency report |
7. Production Readiness Checklist
8. Timeline Summary
Week 1-2: Telemetry infrastructure setup
Week 3-4: Baseline measurement collection
Week 5-8: Prefetch evaluation
Week 9-12: SXG evaluation
Week 13-16: FatPack evaluation
Week 17-18: Cross-technology analysis
Week 19-20: Production recommendations
9. Tools & Stack Recommendations
Must-have:
- WebPageTest private instances for controlled testing
- Chrome User Experience Report (CrUX) for comparison
- Lighthouse CI for regression detection
- Prometheus/Grafana for real-time monitoring
Nice-to-have:
- RUM (Real User Monitoring) solution (SpeedCurve, New Relic)
- Browsertime for automated testing
- s7g (SXG generator) for local testing
- Web Packaging Playground for demos
10. Decision Framework
For each technology, answer:
| Criterion | Weight | Prefetch | SXG | FatPack |
|---|
| Performance gain | 30% | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐ |
| Implementation complexity | 25% | ⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ |
| Browser support | 20% | ⭐⭐⭐⭐ | ⭐⭐ | ⭐⭐ |
| Operational overhead | 15% | ⭐ | ⭐⭐⭐ | ⭐⭐⭐ |
| Future-proofing | 10% | ⭐⭐ | ⭐⭐⭐ | ⭐ |
Adoption Recommendation Threshold: Weighted score > 3.0/5.0
Immediate Next Steps:
-
Week 1 Priority:
- Deploy basic telemetry (Navigation Timing + Resource Timing)
- Set up A/B test framework
- Establish baseline metrics for 2 weeks
-
Stakeholder Alignment:
- Present this plan to Infrastructure, Security, and Product teams
- Get buy-in on traffic allocation percentages
- Define success criteria with product metrics team
-
Parallel Workstreams:
- Security review: SXG certificate management
- Legal review: SXG trust model implications
- CDN partnerships: Coordinate with CDN providers for SXG support
Would you like me to elaborate on any specific component, such as the telemetry schema details, experiment design for a particular technology, or the statistical analysis plan?