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 одговора (на страни 1 од 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.

Не можеш да нађеш филм или серију? Пријави се да додаш.

Глобално

s фокусирај траку за претрагу
p отворите мени профила
esc затворити отворени прозор
? отвори прозор пречице на тастатури

На страницама медија

b вратити се назад (или родитељу кад је то применљиво)
e иди на страницу за уређивање

На страницама ТВ сезона

(стрелица надесно) пређите на следећу сезону
(лева стрелица) иди на претходну сезону

На страницама ТВ епизода

(стрелица надесно) пређите на следећу епизоду
(лева стрелица) иди на претходну епизоду

На свим страницама са сликама

a отвори прозор за додавање слике

На свим страницама за уређивање

t отвори селектор превода
ctrl+ s пошаљи образац

На страницама за дискусију

n отвори нову дискусију
w мења статус гледања
p мења јавно/приватно
c мења отвори/затвори
a отвори активност
r одговор на дискусију
l иди на последњи одговор
ctrl+ enter пошаљи поруку
(стрелица надесно) следећа страница
(лева стрелица) претходна страница

Подешавања

Желите ли да оцените или додате ову ставку у листу?

Пријави се