Soporte de The Movie Database

Hi,

I was just wondering what the recommended way of caching is. Is there only ETag? Should one use ETag for caching?

As far as I can tell If-Modified-Since is not supported. Is there any plans of making the HTTP response include the last-change date so I can send requests with If-Modified-Since header?

Cheers, Reinhard

14 respuestas (en la página 1 de 1)

Jump to last post

Actually ETag doesn't seem to work.

Request is setting If-None-Match correctly but server is responding with 200 OK + data instead of just rending back a 304 Not Modified: http://snag.gy/mIkt9.jpg

Have you taken a look at this thread: https://www.themoviedb.org/talk/5162e6e8760ee374b610b24e

(my bad, had If-Modified-Since set which apparently cancels out If-None-Match)

Got it working now. Just need to make sure If-Modified-Since is not set if If-None-Match is set. Though why the above curl call didn't work is beyond me...

If I get back "304 Not Modified" does the request count towards the rate limit?

Hi rednoah,

It will count towards the rate limit. The benefit is the saved transfer on both our end and your client(s). This results in less resources being used all round and just being a better API consumer.

I am trying to use etags but it does not seem to work for me.

Can anyone see what I am doing wrong?

$curl -v "http://api.themoviedb.org/3/movie/100?api_key=<API_KEY>"

> GET /3/movie/100?api_key=<API_KEY> HTTP/1.1
> User-Agent: curl/7.29.0
> Host: api.themoviedb.org
> Accept: */*
> 
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Cache-Control: public, max-age=21600
< Content-Type: application/json;charset=utf-8
< Date: Tue, 21 Jan 2014 14:37:17 GMT
< ETag: "9f130298115875afd8c388811f36b5d9"
< Server: nginx
< Status: 200 OK
< Vary: Accept-Encoding
< X-Memc: HIT
< X-Memc-Age: 17505
< X-Memc-Expires: 4095
< X-Memc-Key: 61cc0041578d58eb840511afd0338bc1
< Content-Length: 1174
< Connection: keep-alive
< 
{"adult":false,"backdrop_path":"/lBpl3aIprl25iOPqjc2JiOSd7eT.jpg"...}

So here we can see the etag is:

< ETag: "9f130298115875afd8c388811f36b5d9"

Now I pass that same etag in the If-None-Match header...

$curl -v --header 'If-None-Match: "9f130298115875afd8c388811f36b5d9"' "http://api.themoviedb.org/3/movie/100?api_key=<API_KEY>"

> GET /3/movie/100?api_key=<API_KEY> HTTP/1.1
> User-Agent: curl/7.29.0
> Host: api.themoviedb.org
> Accept: */*
> If-None-Match: "9f130298115875afd8c388811f36b5d9"
> 
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Cache-Control: public, max-age=21600
< Content-Type: application/json;charset=utf-8
< Date: Tue, 21 Jan 2014 14:40:41 GMT
< ETag: "9f130298115875afd8c388811f36b5d9"
< Server: nginx
< Status: 200 OK
< Vary: Accept-Encoding
< X-Memc: HIT
< X-Memc-Age: 17709
< X-Memc-Expires: 3891
< X-Memc-Key: 61cc0041578d58eb840511afd0338bc1
< Content-Length: 1174
< Connection: keep-alive
{"adult":false,"backdrop_path":"/lBpl3aIprl25iOPqjc2JiOSd7eT.jpg"...}

I still get a 200 response and the entity.

What have I missed?

I can replicate this, I suspect the change was caused when we removed Varnish from our stack. I'll have to spend some time digging into this and seeing if we can take care of this properly at the app level.

Here's the relevant ticket.

Cheers.

Is this problem solved because I that same issue too.. Even if I send the If-None-Match I still get 200

No, the problem is not fixed yet. The ticket is still open.

3.5 years later, still looks like etag isn't working:

curl -i -H Accept:application/json -H If-None-Match:df2617d2ab5d0c85ceff5098b8ab70c4 -X GET 'https://api.themoviedb.org/3/genre/movie/list?language=en-US&api_key=API_KEY'

I still get 200

That is correct, it hasn't been fixed yet. I do not have an ETA for this issue at this time.

Still not fixed? :/ I really need this.

By the way, If-None-Match works on most API calls now (the ones that return an ETag). I'll try to find some time to get the remaining methods that aren't returning an ETag completed soon.

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...

Responds with a regular 200 response, and if we make a call with If-None-Match...

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

We're properly returning a 304. thumbsup_tone2

Cheers.

¿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