
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Hishel - An elegant HTTP Cache implementation for httpx and httpcore.
Hishel (հիշել, remember) is a library that implements HTTP Caching for HTTPX and HTTP Core libraries in accordance with RFC 9111, the most recent caching specification.
Vary
, Etag
, Last-Modified
, Cache-Control
, and Expires
headers, and handles response re-validation automatically.Go through the Hishel documentation.
Install Hishel
using pip:
$ pip install hishel
Let's begin with an example of a httpx client.
import hishel
with hishel.CacheClient() as client:
client.get("https://hishel.com") # 0.4749558370003797s
client.get("https://hishel.com") # 0.002873589000046195s (~250x faster!)
or in asynchronous context
import hishel
async with hishel.AsyncCacheClient() as client:
await client.get("https://hishel.com")
await client.get("https://hishel.com") # takes from the cache
Configure when and how you want to store your responses.
import hishel
# All the specification configs
controller = hishel.Controller(
# Cache only GET and POST methods
cacheable_methods=["GET", "POST"],
# Cache only 200 status codes
cacheable_status_codes=[200],
# Use the stale response if there is a connection issue and the new response cannot be obtained.
allow_stale=True,
# First, revalidate the response and then utilize it.
# If the response has not changed, do not download the
# entire response data from the server; instead,
# use the one you have because you know it has not been modified.
always_revalidate=True,
)
# All the storage configs
storage = hishel.S3Storage(
bucket_name="my_bucket_name", # store my cache files in the `my_bucket_name` bucket
ttl=3600, # delete the response if it is in the cache for more than an hour
)
client = hishel.CacheClient(controller=controller, storage=storage)
# Ignore the fact that the server does not recommend you cache this request!
client.post(
"https://example.com",
extensions={"force_cache": True}
)
# Return a regular response if it is in the cache; else, return a 504 status code. DO NOT SEND A REQUEST!
client.post(
"https://example.com",
headers=[("Cache-Control", "only-if-cached")]
)
# Ignore cached responses and do not store incoming responses!
response = client.post(
"https://example.com",
extensions={"cache_disabled": True}
)
The responses are stored by Hishel
in storages.
You have complete control over them; you can change storage or even write your own if necessary.
You can support the project by simply leaving a GitHub star ⭐ or by contributing. Help us grow and continue developing good software for you ❤️
Date
header is not present. (#273)AssertionError
on client.close()
when use SQLiteStorage. (#269)force_cache
. (#271)cache_private
property to the controller to support acting as shared cache. (#224)FileStorage
by reducing number of syscalls. (#252)remove
support for storages (#241)revalidated
response extension. (#242)RedisStorage
when using without ttl. (#231)AsyncBaseStorage
and BaseStorage
. (#220)force_cache
property to the controller, allowing RFC9111 rules to be completely disabled. (#204).gitignore
to cache directory created by FIleStorage
. (#197)stale_*
headers from the CacheControl
class. (#199)botocore is not installed
exception when using any kind of storage. (#186)S3Storage
to check staleness of all cache files with set interval. (#182)FileCache
could cause a parsing error. (#181)POST
and other HTTP methods. (#183)FileStorage
to check staleness of all cache files with set interval. (#169)typing_extensions
from requirements.txt to pyproject.toml. (#161)force_cache
extension to enforce the request to be cached, ignoring the HTTP headers. (#117)cache_disabled
extension to temporarily disable the cache (#109)datetime.datetime.utcnow()
to datetime.datetime.now(datetime.timezone.utc)
since datetime.datetime.utcnow()
has been deprecated. (#111)Last-Modified
validation.install_cache
function. (#95)ttl
argument to BaseStorage
class. (#94)AsyncResponseStream
with AsyncCacheStream
. (#86)must-understand
response directive support. (#90)cache-control
directives. (#42)Heuristic Freshness
. (#11)Controller.cache_heuristically
to Controller.allow_heuristics
. (#12)Vary
header validation. (#8)YamlSerializer
name to YAMLSerializer
.from_cache
response extension.typing_extensions
into the requirements.FAQs
Persistent cache implementation for httpx and httpcore
We found that hishel demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.