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

Support If-Modified-Since headers in the APIs #23

Closed
ArthurAllshire opened this issue Mar 2, 2018 · 11 comments · Fixed by #37
Closed

Support If-Modified-Since headers in the APIs #23

ArthurAllshire opened this issue Mar 2, 2018 · 11 comments · Fixed by #37

Comments

@ArthurAllshire
Copy link

The TBA API docs recommend using the If-Modified-Since header to save time in your application and reduce load on their servers. Are there currently any plans to implement this as part of tbapy?

@ErikBoesen
Copy link
Member

I've looked into doing this, and the best way I can find is to store fetched data in a local database. This seems like an overly complicated implementation, so I've neglected to do it thus far. I'd love to make use of these headers if anyone can think of a better implementation, though.

@auscompgeek
Copy link

auscompgeek commented Mar 2, 2018

So our team is (currently) using tbapy for a project, which does involve caching data from TBA in a (pseudo-)database. Being able to pass in an If-Modified-Since, and being able to get the Last-Modified returned from the server should be enough for us.

@ErikBoesen
Copy link
Member

Yeah, that makes sense, we should definitely support that. I should have this fix out by later today.

@ErikBoesen
Copy link
Member

@auscompgeek Would you prefer to set a time on instantiating the library, or pass a parameter to every request?

@auscompgeek
Copy link

Passing in an optional date for If-Modified-Since on each request would probably be fine.

@ErikBoesen
Copy link
Member

ErikBoesen commented Mar 2, 2018

In what format would you prefer the date to be passed? (datetime.date, 'Fri, 02 Mar 2018 13:35:08 GMT' formatted date as the API takes in the end, timestamp?)

@ArthurAllshire
Copy link
Author

As long as the return (Last-Modified), and the input back (If-Modified-Since) have the same format, we don't really mind. We can store whatever data type (we are caching the Last-Modified time via a pickle), just whatever you think makes most sense as part of the API.

@ErikBoesen
Copy link
Member

I think it seems most reasonable to handle it with timestamps.

@ErikBoesen
Copy link
Member

Sorry I didn't get to this earlier. I'm working on it now.

@ErikBoesen
Copy link
Member

ErikBoesen commented Mar 8, 2018

How do you want to get the returned headers?

@NikhilNarayana
Copy link
Contributor

NikhilNarayana commented May 6, 2018

Could the header just be a variable of the classes? I don't understand how you built those classes so I'm not sure how to implement that.

Another idea I had is using a CacheControl wrapper on the Session object to provide minimal caching for all users, but that is meant for people that want to get the same request path over and over (I'll admit I'm very guilty of this so I think the wrapper is a great idea).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants