Soporte de The Movie Database

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 respuestas (en la página 1 de 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.

¿No encuentras una película o serie? Inicia sesión para crearla:

Global

s centrar la barra de búsqueda
p abrir menú de perfil
esc cierra una ventana abierta
? abrir la ventana de atajos del teclado

En las páginas multimedia

b retrocede (o a padre cuando sea aplicable)
e ir a la página de edición

En las páginas de temporada de televisión

(flecha derecha) ir a la temporada siguiente
(flecha izquierda) ir a la temporada anterior

En las páginas de episodio de televisión

(flecha derecha) ir al episodio siguiente
(flecha izquierda) ir al episodio anterior

En todas las páginas de imágenes

a abrir la ventana de añadir imagen

En todas las páginas de edición

t abrir la sección de traducción
ctrl+ s enviar formulario

En las páginas de discusión

n crear nueva discusión
w cambiar el estado de visualización
p cambiar público/privado
c cambiar cerrar/abrir
a abrir actividad
r responder a la discusión
l ir a la última respuesta
ctrl+ enter enviar tu mensaje
(flecha derecha) página siguiente
(flecha izquierda) página anterior

Configuraciones

¿Quieres puntuar o añadir este elemento a una lista?

Iniciar sesión