Skip to content

Unstable ETag because of hash rantomisation #400

Open
@dvarrazzo

Description

@dvarrazzo

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.

"ETag": f"W/{hash(to_cache)}",

As a workaround, setting PYTHONHASHSEED to a fixed value disables hash randomization.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions