tessl install tessl/pypi-requests-cache@1.2.0A persistent cache for python requests
Agent Success
Agent success rate when using this tile
76%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.27x
Baseline
Agent success rate without this tile
60%
A utility module for making HTTP requests with sophisticated client-side cache control capabilities. The module should allow clients to specify how they want to use cached responses through request directives.
@generates
The system should support the max-stale directive, which allows accepting stale cached responses.
The system should support the min-fresh directive, which requires cached responses to remain fresh for a specified duration.
The system should support the only-if-cached directive for offline operation.
The system should handle combinations of cache control directives.
"""
Cache Manager module for HTTP requests with client-side cache control.
This module provides functionality to make HTTP GET requests with
sophisticated cache control through request directives.
"""
def fetch_with_cache_control(url: str, cache_control: dict) -> dict:
"""
Fetch a URL with specified client-side cache control directives.
Args:
url: The URL to fetch
cache_control: Dictionary containing cache control directives:
- 'max_stale': int or True (seconds or unlimited)
- 'min_fresh': int (seconds)
- 'only_if_cached': bool
Returns:
dict with keys:
- 'content': Response content (str)
- 'from_cache': Whether response came from cache (bool)
- 'age': Age of cached response in seconds (int or None)
- 'status': HTTP status code or 504 for cache miss with only_if_cached
Raises:
ValueError: If cache_control contains invalid directives
"""
pass
def clear_cache():
"""
Clear all cached responses.
"""
pass
def get_cache_info() -> dict:
"""
Get information about the current cache state.
Returns:
dict with keys:
- 'size': Number of cached responses (int)
- 'urls': List of cached URLs (list)
"""
passProvides HTTP caching with Cache-Control support.
@satisfied-by