Поддръжка на 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 изпращане на вашето съобщение
(стрелка надясно) следваща страница
(стрелка наляво) предишна страница

Настройки

Искате ли да го оцените или добавите към списък?

Вход