tessl install tessl/pypi-hishel@0.1.0Persistent cache implementation for httpx and httpcore following RFC 9111 specification
Agent Success
Agent success rate when using this tile
74%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.48x
Baseline
Agent success rate without this tile
50%
A diagnostic tool that monitors and reports on HTTP caching behavior by tracking cache state transitions and operations.
Build a cache state tracking system that wraps an HTTP client with caching capabilities and provides detailed insights into caching operations. The system should track when responses are served from cache, when cache misses occur, when revalidation happens, and when responses are stored.
Your implementation should handle multiple caching scenarios including fresh cache hits, cache misses, stale response revalidation, and responses that cannot be cached.
The system must provide:
@generates
class CacheStateTracker:
"""
Tracks HTTP caching state transitions and operations.
"""
def __init__(self, base_url: str):
"""
Initialize the cache state tracker.
Args:
base_url: The base URL for HTTP requests
"""
pass
def get(self, path: str) -> dict:
"""
Make a GET request and track caching behavior.
Args:
path: The URL path to request
Returns:
Response data as a dictionary
"""
pass
def get_stats(self) -> dict:
"""
Get cache statistics.
Returns:
Dictionary with keys:
- total_requests: Total number of requests made
- cache_hits: Number of responses served from cache
- cache_misses: Number of requests that went to origin
- revalidations: Number of stale responses revalidated
- stored_responses: Number of responses stored in cache
"""
pass
def reset_stats(self):
"""
Reset all statistics to zero.
"""
passProvides HTTP caching support with state machine implementation.