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 simple HTTP caching utility that automatically revalidates stale cached responses using conditional requests.
Build a tool that stores HTTP responses in a cache and automatically revalidates them when they become stale. When a cached response needs revalidation, the tool should send conditional HTTP requests using validator headers to check if the content has changed, allowing efficient bandwidth usage through 304 Not Modified responses.
@generates
from typing import Optional, Dict
class CachedResponse:
"""Represents a cached HTTP response with validators."""
url: str
status_code: int
body: str
etag: Optional[str]
last_modified: Optional[str]
headers: Dict[str, str]
class ConditionalRequest:
"""Represents a conditional HTTP request for revalidation."""
url: str
headers: Dict[str, str]
class CacheValidator:
"""HTTP cache validator with conditional request support."""
def store_response(self, response: CachedResponse) -> None:
"""Store a response in the cache."""
pass
def create_conditional_request(self, url: str) -> Optional[ConditionalRequest]:
"""
Create a conditional request for revalidating a cached response.
Generates If-None-Match if ETag exists, otherwise If-Modified-Since if Last-Modified exists.
Returns None if no cached response exists.
"""
pass
def handle_revalidation_response(
self,
url: str,
status_code: int,
body: str,
headers: Optional[Dict[str, str]] = None
) -> CachedResponse:
"""
Handle revalidation response and update cache.
For 304: merge headers into cached response, keep original body.
For 200: replace entire cached response with new data.
"""
pass
def get_cached_response(self, url: str) -> Optional[CachedResponse]:
"""Retrieve a cached response by URL."""
passProvides HTTP caching with RFC 9111 compliance including conditional request generation and 304 Not Modified handling.
@satisfied-by