Persistent cache implementation for httpx and httpcore following RFC 9111 specification
74
Build a Python HTTP client utility that adds persistent caching capabilities to the requests library.
Create a module that provides a configured HTTP session with caching enabled.
Create a function create_cached_session() that returns a requests Session object with the following caching configuration:
http:// and https:// URL schemes.cache/http_cache.dbAfter making requests with the session, it should be possible to inspect response metadata to determine:
https://httpbin.org/json results in the first response being stored and the second retrieved from cache @test@generates
from requests import Session
def create_cached_session() -> Session:
"""
Creates and returns a requests Session with persistent caching enabled.
The session uses an adapter-based caching mechanism that stores responses
in a SQLite database with a 5-minute default TTL.
Returns:
Session: A configured requests Session object with caching support
"""
passProvides HTTP caching capabilities through adapter integration with requests.
@satisfied-by
HTTP library for making requests.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-hisheldocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10