Skip to content
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

Add options for setting Cache-Control #1

Open
faultyserver opened this issue Sep 17, 2016 · 1 comment
Open

Add options for setting Cache-Control #1

faultyserver opened this issue Sep 17, 2016 · 1 comment

Comments

@faultyserver
Copy link
Member

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.

@faultyserver
Copy link
Member Author

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 almost 100% sure that propershark/tripspark_api#1 is a result of this same problem.

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.

faultyserver added a commit to propershark/shark that referenced this issue Sep 24, 2016
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant