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
I don't see any mention of conditional GET requests. If it's not supported, I'd certainly like it added. If it is supported, perhaps the readme could be updated?
Specifically, what I'm looking for is:
If I make an API request outside of the period, hit the API with appropriate If-Modified-Since and If-None-Match headers, and if the response is a 304 - Not Modified, then serve the cached response.
The text was updated successfully, but these errors were encountered:
This feature doesn't exist, but I agree it's a very good idea.
I just had a look at the code to see how this could work. My impression is that rather than building this into the built in HTTP code (which is really just a convenience thing, and which I probably wouldn't add if I was building this again), you want to make it possible to use the previous cached value in the block provided to APICache.get. This way you could store the etag in the cache, and set the appropriate headers when making the HTTP request. One solution would be to pass the Cache object for that key as a block parameter to APICache.get - so in pseudocode you'd be able to write
APICache.get('some_key') do |cache|
if cache.exists?
etag = JSON.parse(cache.get)[:etag]
make_http_request(etag: etag)
else
make_http_request
end
# ... return etag and body for storage in the cache
end
I'm very happy to accept a pull request for something along these lines :)
On 13 Jun 2012, at 23:45, Mark Pundsack wrote:
I don't see any mention of conditional GET requests. If it's not supported, I'd certainly like it added. If it is supported, perhaps the readme could be updated?
Specifically, what I'm looking for is:
If I make an API request outside of the period, hit the API with appropriate If-Modified-Since and If-None-Match headers, and if the response is a 304 - Not Modified, then serve the cached response.
Reply to this email directly or view it on GitHub: #7
I don't see any mention of conditional GET requests. If it's not supported, I'd certainly like it added. If it is supported, perhaps the readme could be updated?
Specifically, what I'm looking for is:
If I make an API request outside of the
period
, hit the API with appropriate If-Modified-Since and If-None-Match headers, and if the response is a 304 - Not Modified, then serve the cached response.The text was updated successfully, but these errors were encountered: