-
-
Notifications
You must be signed in to change notification settings - Fork 191
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Milestone
Description
Python hash() function is salted by default (see hash docs). Therefore the hash of the same object doesn't normally produce the same value in different processes.
As a result, because of the way ETags are produced, the cache gets invalidated when the service restarts. Or, if the service is deployed with more than one backend behind a load balancer, every backend will return a different etag for the same resource, making it useless.
fastapi-cache/fastapi_cache/decorator.py
Line 201 in 91ba6d7
| "ETag": f"W/{hash(to_cache)}", |
As a workaround, setting PYTHONHASHSEED to a fixed value disables hash randomization.
vvanglro, IOR88, edziegle and ermiyaeskandary
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers