The Movie Database-ondersteuning

How are we meant to cache the request? Theres no ETag or anything. As in, how are we meant to check if for example: api/3/{movie/tv}/{tmdbid} is updated? I can cache using localStorage, but how am I meant to know if I should use the cached version, or re-grab. Is there any /sync/last_activities like Trakt?

10 antwoorden (op pagina 1 van 1)

Jump to last post

pragma account cracker, movie watcher :))

Hey @PRAGMA,

Etags have been restored. I thought it was odd to hear it wasn't present as I know I looked into this years ago and indeed, it was a bug introduced a few months ago.

ETag isnt on /discover is this expected?

Yes, for now. Etags were easy to restore on our Ruby stack. People, discover, search, lists and v4, are all on our Lua stack. That's an entirely different thing.

Alright, and just to confirm, I should store the Etag on first request, and then when re-doing the request, do If-None-Match: and that will send the request but wont count towards rate-limit right?

That's the correct strategy yes, but I don't believe our rate limiting is sophisticated enough to not make that request count. I believe it still counts.

Then wouldnt using Etag on /movie/{id}/ essentially useless?

Not really, it saves you from downloading the response. In any case, none of this has really ever been supported (etags didn't even work for ~3 months)

One day perhaps things will get an update to be smarter about this, but in order to make the rate limiting aware of If-None-Match is actually a huge re-factor of the way our infrastructure works today. Rate limiting stands in front of our app infrastructure as a standalone service so it has no idea what happens once you've been allowed through. A 200, 404 or HEAD, are all the same to it.

But doing an Etag still responds a JSON result though?

Yes, if the response has changed. It's a conditional call, look at the following as examples:

curl -v https://api.themoviedb.org/3/movie/550?api_key=###
*   Trying 54.221.197.78...
* Connected to api.themoviedb.org (54.221.197.78) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.themoviedb.org
* Server certificate: RapidSSL SHA256 CA
* Server certificate: GeoTrust Global CA
> GET /3/movie/550?api_key=### HTTP/1.1
> Host: api.themoviedb.org
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After
< Cache-Control: public, max-age=28800
< Content-Type: application/json;charset=utf-8
< Date: Sun, 25 Feb 2018 16:42:52 GMT
< ETag: "90b9fc692a09251719e494efb0b300c4"
< Server: openresty
< Vary: Accept-Encoding
< X-Memc: HIT
< X-Memc-Age: 13814
< X-Memc-Expires: 14986
< X-Memc-Key: a7a8be33582080c3e162cfcb93607b73
< X-RateLimit-Limit: 40
< X-RateLimit-Remaining: 39
< X-RateLimit-Reset: 1519576982
< Content-Length: 1367
< Connection: keep-alive
<
* Connection #0 to host api.themoviedb.org left intact
{"adult":false,"backdrop_path":"/87hTDiay2N2qWyX4Ds7ybXi9h8I.jpg","belongs_to_collection":null...

Repsonds with the body as a regular 200 response. Now if we make another request with the ETag we got back in the first request, you'll see it responds with no body, as a 304 response.

curl -v --header 'If-None-Match: "90b9fc692a09251719e494efb0b300c4"' https://api.themoviedb.org/3/movie/550?api_key=###
*   Trying 54.221.197.78...
* Connected to api.themoviedb.org (54.221.197.78) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.themoviedb.org
* Server certificate: RapidSSL SHA256 CA
* Server certificate: GeoTrust Global CA
> GET /3/movie/550?api_key=### HTTP/1.1
> Host: api.themoviedb.org
> User-Agent: curl/7.43.0
> Accept: */*
> If-None-Match: "90b9fc692a09251719e494efb0b300c4"
>
< HTTP/1.1 304 Not Modified
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After
< Cache-Control: public, max-age=28800
< Content-Type: application/octet-stream
< Date: Sun, 25 Feb 2018 16:43:37 GMT
< ETag: "90b9fc692a09251719e494efb0b300c4"
< Server: openresty
< X-Memc: HIT
< X-Memc-Age: 13859
< X-Memc-Expires: 14941
< X-Memc-Key: a7a8be33582080c3e162cfcb93607b73
< X-RateLimit-Limit: 40
< X-RateLimit-Remaining: 39
< X-RateLimit-Reset: 1519577027
< Connection: keep-alive
<
* Connection #0 to host api.themoviedb.org left intact

Now, let's say the ETag changes (I'll fake this by changing the ETag I query):

curl -v --header 'If-None-Match: "90b9fc692a09251719e494efb0b300c9"' https://api.themoviedb.org/3/movie/550?api_key=###
*   Trying 54.243.110.77...
* Connected to api.themoviedb.org (54.243.110.77) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.themoviedb.org
* Server certificate: RapidSSL SHA256 CA
* Server certificate: GeoTrust Global CA
> GET /3/movie/550?api_key=### HTTP/1.1
> Host: api.themoviedb.org
> User-Agent: curl/7.43.0
> Accept: */*
> If-None-Match: "90b9fc692a09251719e494efb0b300c9"
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After
< Cache-Control: public, max-age=28800
< Content-Type: application/json;charset=utf-8
< Date: Sun, 25 Feb 2018 16:44:11 GMT
< ETag: "90b9fc692a09251719e494efb0b300c4"
< Server: openresty
< Vary: Accept-Encoding
< X-Memc: HIT
< X-Memc-Age: 13893
< X-Memc-Expires: 14907
< X-Memc-Key: a7a8be33582080c3e162cfcb93607b73
< X-RateLimit-Limit: 40
< X-RateLimit-Remaining: 39
< X-RateLimit-Reset: 1519577060
< Content-Length: 1367
< Connection: keep-alive
<
* Connection #0 to host api.themoviedb.org left intact
{"adult":false,"backdrop_path":"/87hTDiay2N2qWyX4Ds7ybXi9h8I.jpg","belongs_to_collection":null...

You get another 200 response with the body and a new ETag.

Film of tv-serie niet gevonden? Log dan in om deze te creëren.

Wereldwijd

s focus op zoekbalk
p open profielmenu
esc sluit een open venster
? open sneltoetsen venster

Op media pagina's

b ga terug (of ga naar bovenliggend item)
e ga naar beweken

Op TV seizoenspagina's

(rechter pijl) ga naar volgende seizoen
(linker pijl) ga naar vorig seizoen

Op pagina's met TV-programma's

(rechter pijl) ga naar volgende aflevering
(linker pijl) ga naar vorige aflevering

Op alle afbeeldingspagina's

a open venster afbeelding toevoegen

Op alle bewerkte pagina's

t open vertaalmenu
ctrl+ s verstuur formulier

Op discussiepagina's

n start nieuwe discussie
w Verander kijk status
p privé of openbaar
c gesloten of open
a open activiteit
r beantwoord discussie
l ga naar laatste antwoord
ctrl+ enter verstuur uw bericht
(rechter pijl) volgende pagina
(linker pijl) vorige pagina

Instellingen

Want to rate or add this item to a list?

Inloggen