-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caching middleware can generate cache keys with #cache_key which are too long #132
Labels
Comments
Anyone there? ❤️ |
@timrogers sorry for being late on this one. Hashing the |
Happy to look at this. Shouldn't be too complicated. |
timrogers
pushed a commit
to timrogers/faraday_middleware
that referenced
this issue
Sep 19, 2018
Issue lostisland#132 notes that the caching middleware can generate keys which are too long when the input is a complex URL, leading to errors like `Errno::ENAMETOOLONG: File name too long @ rb_sysopen`. (The effective length limit depends on what cache driver you're using.) At the moment, we use the normalised request URI as the cache key. The fixes the issue by using `Digest::SHA1.hexdigest` to hash the URLs, giving us a constant 20-byte result. The trade-off of using a hash is that: * there is the potential for collisions (as rare as they will realistically be!) * performing a hash takes time
timrogers
pushed a commit
to timrogers/faraday_middleware
that referenced
this issue
Nov 26, 2018
Issue lostisland#132 notes that the caching middleware can generate keys which are too long when the input is a complex URL, leading to errors like `Errno::ENAMETOOLONG: File name too long @ rb_sysopen`. (The effective length limit depends on what cache driver you're using.) At the moment, we use the normalised request URI as the cache key. The fixes the issue by using `Digest::SHA1.hexdigest` to hash the URLs, giving us a constant 20-byte result. The trade-off of using a hash is that: * there is the potential for collisions (as rare as they will realistically be!) * performing a hash takes time
Fixed in #181 🎉! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#cache_key
inFaradayMiddleware::Caching
(https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/response/caching.rb#L61) can generate cache keys that are too long for complex URLs.This can lead to errors like
Errno::ENAMETOOLONG: File name too long @ rb_sysopen
.I'm not really sure how best to go about fixing this, as obviously the uniqueness is important as it makes the cache per-identical request. Perhaps we could hash the keys in some way to get them to a uniform, shorter length?
The text was updated successfully, but these errors were encountered: