Request Cache / Inspect Request?

32 views
Skip to first unread message

Andrew Burleson

unread,
May 20, 2016, 11:02:18 AM5/20/16
to http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API
Two related questions:

1) Is there any existing system / tool for caching requests made via the HTTP gem?

For example: I'm writing an application where we have an API that we read-only, but we have to fetch a lot of data. The data changes regularly and we don't want to download a copy, but it doesn't change constantly. It would be a useful tradeoff to cache responses from that API for say, 5 minutes, so that the lag of fetching that stuff was infrequent, and users would be fine with "it may take up to 5 minutes for changes to show up."

2) As a direct follow up, assuming there's no existing plugin or anything that does this, is it possible to get the Request object and inspect the exact URL / headers that were passed for a request?

Specifically, my get requests almost always have query params. I'm happily taking advantage of HTTP gem's great syntax for this, that means there's nowhere in my app code where I have the full URL string.

So if you're doing something like:

HTTP.get "http://example.com/example/foo", params:{q:"bar"}

Is there anyway to get the actual URL that HTTP generates? ie.


Thanks!
Andrew


Tony Arcieri

unread,
May 22, 2016, 3:04:39 PM5/22/16
to Andrew Burleson, http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API
We had a caching system based on rack-cache at one point, but removed it due to performance and code maintainability problems, as well as the Rack dependency.

Here's some preliminary work to add it back:

--
You received this message because you are subscribed to the Google Groups "http.rb: a fast, easy-to-use Ruby HTTP client with a chainable API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to httprb+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Tony Arcieri

Reply all
Reply to author
Forward
0 new messages