kenkoooo / AtCoderProblems

Extend your AtCoder
https://kenkoooo.com/atcoder/
MIT License
1.41k stars 150 forks source link

Information regarding https://kenkoooo.com/atcoder/resources/merged-problems.json #1374

Closed ankur-kayal closed 1 year ago

ankur-kayal commented 1 year ago

Hi Team,

I am planning to use this api: https://kenkoooo.com/atcoder/resources/merged-problems.json for one of my personal hobby projects. I need some information and clarification regarding this api endpoint:

  1. How often is this information updated?
  2. I am planning to hit this endpoint once in every 5 minutes. Is this okay with you guys?

Thanks.

kenkoooo commented 1 year ago

Thank you for the clarification!

How often is this information updated?

It's updated after a contest is over. That means it's updated at most twice a week.

I am planning to hit this endpoint once in every 5 minutes. Is this okay with you guys?

Yes, you can, if you handle 304 responses: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304

Once you get a JSON file, please add an HTTP header If-Modified-Since. If the file is updated, the server will return the new file with 200. If there's no update, the server will return an empty response body with 304.

Thanks!

ankur-kayal commented 1 year ago

Hi @kenkoooo I think this file is updated more than 2 times a week, I ran my script for about 12 hours and it has updated more than 3 times already. Is this expected?

kenkoooo commented 1 year ago

@ankur-kayal I didn't notice. How were they different?

ankur-kayal commented 1 year ago

I am not logging that but checked that the If-last-modified header indeed change. And it matches with my logs.

kenkoooo commented 1 year ago

I guess the file content wasn't updated. The header was automatically updated by AWS. I didn't expect that behavior, but it shouldn't be a problem. You don't need to change your logic. Thank you for putting If-Modified-Since header.