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
It'd be nice if I could remember how I implemented things from the beginning...
By default, most API methods are memoized, meaning that requests with the same parameters will use a local cache, rather than resending requests to the source.
While this is great from an efficiency standpoint, and is mostly desirable behavior, it requires users to either add an additional true parameter to reset the cache at call time, or call #flush_cache on the containing object before making a new request.
The cause of propershark/shark#29 is that the user is not flushing the cache between update cycles, and so after the first request, every subsequent cycle will use the local cache (the parameters never change). The best fix for this would be to include an api.flush_cache call at the top of refresh in each source.
I'm not going to close this issue yet, since I do think there should be some top-level configuration option for enabling/disabling the cache system, but the immediate issue should be resolved.
The issue wasn't that the HTTP requests were getting cached, but that the API library (that I wrote, and should have remembered) uses `memoize` on most of its methods, and the Sources here never tried to flush those local caches.
To fix this, the `refresh` method for each source now includes an `api.flush_cache` call, which should ensure that a new request is made for every cycle.
Note that this solution will hopefully change with the actual fix mentioned in propershark/doublemap_api#1, where there is a global configuration option for caching.
See propershark/shark#29. There should be an option for specifying the
Cache-Control
headers on every request.Since the DoubleMap API is real-time, I think it makes sense to disable caching by default, and allow users to opt-in for individual requests.
See this SO question about how to ensure Caching is always disabled.
The text was updated successfully, but these errors were encountered: