You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be nice to have some form of Response caching here, with a simple Hash Store and Memcache API Store, seeing how Github itself doesn't count successfull Conditional Gets towards the API limit.
Finally took the time to look at resourceful, looks like it has everything "http" misses and has a adapter API, guess I'll just write one for the http gem :)
FWIW, Resourceful is not really maintained anymore. If it works for you, great, otherwise I'd be happy to have similar features built into the HTTP gem itself.
I guess ill just read rfc2616-sec13 and rfc2616-sec14.9 and implement it on my own without looking elsewhere, resourceful implements it in a way at least i cannot validate with what is written in rfc2616.
Upon reading the spec sections twice i belive its mostly spec compliant, there is just one catch.
When a response doesn't include max-age or Expire headers it will be cached forever, guess that needs a extra section in the README so request.headers['Cache-Control'] include a max-age value when you don't want something cached forever.
Its especially important to note when HTTP is used as a API Client, some services properly speak http (github for instance) so you can cache their responses, while others ( etcd ) don't.
What is mostly missing now are comments and specs, i can add the former over time, but desperately need help with specs, never wrote them before and my free time is rather limited for the rest of the year.
@Asmod4n well default adapter does not needs to be class exactly. It was a simplification. So I assume it might be something like this: InMemoryAdapter.current:
classHTTP::Cache::InMemoryAdapter# Default instance of cache adapterdefself.current@current ||= newendend
Could someone else take https://github.com/Asmod4n/http/compare/caching over? I am afraid i don't use http.rb anymore and haven't found fixes for some pitfalls for caching (attackers can allocate any amount of ram they want with certain conditions).
A Faraday Adapter would be good, but there are gems which don't even work with faraday if you don't use Net::HTTP (octokit.rb doesn't work with typhoeus for instance)
@Asmod4n I don't think I will be able to jump anytime soon on this issue, but I would like to keep it open if anybody would like to jump on. I have merged your caching branch of your repo into wip/caching-support on this repo.
Activity
tarcieri commentedon Feb 3, 2014
Here's a library to look to for ideas:
https://github.com/paul/resourceful
I think this would be a cool feature to have, particularly if it were opt-in and off by default (so as not to affect what @sferik is doing ;)
tarcieri commentedon Feb 3, 2014
Another one (using Celluloid):
https://github.com/paul/hippie
Asmod4n commentedon Feb 20, 2014
Finally took the time to look at resourceful, looks like it has everything "http" misses and has a adapter API, guess I'll just write one for the http gem :)
tarcieri commentedon Feb 20, 2014
FWIW, Resourceful is not really maintained anymore. If it works for you, great, otherwise I'd be happy to have similar features built into the HTTP gem itself.
Asmod4n commentedon Feb 27, 2014
Made a rough caching implementation at https://github.com/Asmod4n/http/compare/caching, could need some help with docs and specs ^^
@tarcieri @ixti @sferik
Asmod4n commentedon Feb 27, 2014
Am having issues unrelated to this patch, redirects write headers servers don't seam to understand.
HTTP.with_follow(true).get('http://google.com/')
Asmod4n commentedon Feb 27, 2014
it sends
upon redirects oO
Asmod4n commentedon Feb 28, 2014
I guess ill just read rfc2616-sec13 and rfc2616-sec14.9 and implement it on my own without looking elsewhere, resourceful implements it in a way at least i cannot validate with what is written in rfc2616.
For ex: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.2 says "no-store" send from origin servers must delete the cache entry, resourceful only checks for it in requests.
ixti commentedon Feb 28, 2014
@Asmod4n I like the idea of implementing it RFC-compliant. About redirects - it's a defect indeed, thanks for mentioning that.
Asmod4n commentedon Mar 18, 2014
Upon reading the spec sections twice i belive its mostly spec compliant, there is just one catch.
When a response doesn't include max-age or Expire headers it will be cached forever, guess that needs a extra section in the README so request.headers['Cache-Control'] include a max-age value when you don't want something cached forever.
Its especially important to note when HTTP is used as a API Client, some services properly speak http (github for instance) so you can cache their responses, while others ( etcd ) don't.
What is mostly missing now are comments and specs, i can add the former over time, but desperately need help with specs, never wrote them before and my free time is rather limited for the rest of the year.
ixti commentedon Mar 18, 2014
@Asmod4n defect with Host header upon redirects was fixed in master btw.
ixti commentedon Mar 18, 2014
@Asmod4n If I'll find time over next week, I'll try to help, but not promising anything. Would like to propose you following:
Request.newsignature was changed and include proxy options now.cache_modeandcache_adaptersettings into a single one, e.g.Asmod4n commentedon Mar 18, 2014
@ixti got the latest master changes 3 hours ago.
The InMemory Adapter Instance has to be a class variable atm, or else every new request will use a new instance of the adapter, rendering it useless.
ixti commentedon Mar 18, 2014
@Asmod4n well default adapter does not needs to be class exactly. It was a simplification. So I assume it might be something like this:
InMemoryAdapter.current:28 remaining items
Asmod4n commentedon Jan 2, 2015
Could someone else take https://github.com/Asmod4n/http/compare/caching over? I am afraid i don't use http.rb anymore and haven't found fixes for some pitfalls for caching (attackers can allocate any amount of ram they want with certain conditions).
A Faraday Adapter would be good, but there are gems which don't even work with faraday if you don't use Net::HTTP (octokit.rb doesn't work with typhoeus for instance)
ixti commentedon Jan 2, 2015
@Asmod4n I don't think I will be able to jump anytime soon on this issue, but I would like to keep it open if anybody would like to jump on. I have merged your
cachingbranch of your repo intowip/caching-supporton this repo.Asmod4n commentedon Jan 2, 2015
@ixti thanks a lot, i will try to take a look at it after i have read the new HTTP rfcs regarding caching.
ixti commentedon Mar 27, 2015
Closed by #177 which is in master and was released as 0.8.0.pre
sferik commentedon Mar 27, 2015
@ixti This issue should also be moved into the 0.8.0 milestone. Are you able to do that? I’m still getting an error.
ixti commentedon Mar 27, 2015
@sferik Same here.