Suporte do 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 respostas (na 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.

Não consegue encontrar um certo Filme ou Série? Inicie Sessão e adicione-o.

Geral

s focus the search bar
p abrir menu do perfil
esc close an open window
? open keyboard shortcut window

Em páginas de Média

b go back (or to parent when applicable)
e ir para a página de edição

Em Páginas de Temporadas de Séries

(seta para a direita) ir para a próxima temporada
(seta para a esquerda) ir para a temporada anterior

Em Páginas de Episódios de Séries

(seta para a direita) ir para o próximo episódio
(seta para a esquerda) ir para o episódio anterior

Em Todas as Páginas de Imagens

a abrir janela para adicionar imagem

Em Todas as Páginas de Edição

t open translation selector
ctrl+ s submit form

Em Páginas de Discussão

n criar uma nova discussão
w toggle watching status
p toggle public/private
c toggle close/open
a abrir actividade
r reply to discussion
l ir para a última resposta
ctrl+ enter submit your message
(seta para a direita) página seguinte
(seta para a esquerda) página anterior

Definições

Deseja classificar ou adicionar este item a uma lista?

Iniciar Sessão

Ainda não é um membro?

Crie uma Conta e Adere a Comunidade