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

Unusual caching issue when using Trakt ID and extended=full. #77

Closed
mattcomi opened this issue Jun 6, 2019 · 2 comments
Closed

Unusual caching issue when using Trakt ID and extended=full. #77

mattcomi opened this issue Jun 6, 2019 · 2 comments
Labels
Question Help requested

Comments

@mattcomi
Copy link

mattcomi commented Jun 6, 2019

Hi, when I request the next episode of Game of Thrones with extended=full like this:

curl --header "Content-Type: application/json" --header "trakt-api-version: 2" --header "trakt-api-key: REDACTED" https://api.trakt.tv/shows/1390/next_episode?extended=full

I'm getting a response:

{"season":8,"number":6,"title":null,"ids":{"trakt":3465698,"tvdb":7121405,"imdb":"tt6027920","tmdb":1551830,"tvrage":0},"number_abs":73,"overview":null,"rating":6.66667,"votes":69,"comment_count":6,"first_aired":"2019-05-20T01:00:00.000Z","updated_at":"2019-05-19T22:48:09.000Z","available_translations":["ar","be","bg","bs","cn","cs","da","de","el","en","eo","es","fa","fi","fr","he","hr","hu","id","is","it","ja","ka","ko","lb","lt","lv","ml","nl","no","pl","pt","ro","ru","sk","sr","sv","th","tr","tw","uk","uz","vi","zh"],"runtime":55}

Which indicates that there is a next episode of Game of Thrones, which is incorrect.

However, if I removed extended=full, I don't get a response, which is correct. When I examine the headers on the extended=full request, I get this:

HTTP/2 200 
date: Thu, 06 Jun 2019 10:26:12 GMT
content-type: application/json; charset=utf-8
set-cookie: __cfduid=ddc8fd1d73b5b31bc3ed8b3803bc589b21559816772; expires=Fri, 05-Jun-20 10:26:12 GMT; path=/; domain=.trakt.tv; HttpOnly
cache-control: public, max-age=28800
expires: Thu, 06 Jun 2019 18:26:12 GMT
vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-request-id: eaa83593-2b45-4d55-b5c1-832138d6808d
x-runtime: 0.015008
x-xss-protection: 1; mode=block
cf-cached-on: Sun, 19 May 2019 23:26:58 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
cf-cache-status: HIT
server: cloudflare
cf-ray: 4e29afc988dd4d68-PER

Note in particular date is 06 Jun 2019, but cf-cached-on is 19 May 2019. So it looks like Cloudflare is holding onto the value for way too long.

On the other hand, it's possible I'm doing something weird.

I can break through the cache by adding an arbitrary parameter to the URL, but obviously this isn't a great idea.

I'm not sure, but this may be related to #56.

@mattcomi mattcomi changed the title Unusual caching issue Unusual caching issue when using extended=full and trakt ID Jun 6, 2019
@mattcomi mattcomi changed the title Unusual caching issue when using extended=full and trakt ID Unusual caching issue when using Trakt ID and extended=full. Jun 6, 2019
@mattcomi
Copy link
Author

I'm seeing similar behaviour for Archer and Yellowstone at the moment. From my device (in Perth), the next episodes are correct, but in Indianapolis, they are still reporting the previous episodes, which aired yesterday.

@rectifyer
Copy link
Contributor

This is due to the caching at Cloudflare. We cache responses for 8 hours and that would be dependent on their data centers around the world, which is why different locations might return different info. We unfortunately need to keep the cache time higher like this so the API servers don't get increased loads from these more "static" information methods.

@rectifyer rectifyer added the Question Help requested label Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Help requested
Projects
None yet
Development

No branches or pull requests

2 participants