Does making HEAD requests count towards API call limit?
It seems if it does count towards the limit there isn't much of an advantage to use it as opposed to the full request.
Un film, une émission télévisée ou un artiste est introuvable ? Connectez-vous afin de créer une nouvelle fiche.
Vous souhaitez évaluer ou ajouter cet élément à une liste ?
Pas encore membre ?
Réponse de Travis Bell
le 8 avril 2013 à 12h20
Hey Dominic,
HEAD requests do indeed count towards the rate limiting. The intended workflow would be after you've grabbed some data and cached it locally (make sure to store the ETag), you can periodically check the ETag to determine if you need to re-download the entire data.
What I would suggest you do in order to save the additional request is look at making a "conditional GET" request. The primary difference is sending a
If-None-Match
header with your request which will automatically return a304 Not Modified
if the Etag hasn't changed but if it has changed, return the whole response as a regular GET.An example cURL request for this looks like (assuming I had previously cached the ETag):
The response to this request is:
Cheers.
Réponse de Dominic
le 8 avril 2013 à 12h28
That clears up a lot. I guess in a distributed app that would be worth it but I would only be making one set of requests as it's server side so it would seem that getting back a "304 Not Modified" as opposed to a page of JSON data wouldn't be much of a performance advantage. I mean a few ms or even sec delay per request would not be an issue for me and JSON data is only a few bytes/kb. Or am I missing something?
Also what is the advantage of using Etag as opposed to comparing the date modified (Last-Modified: Mon, 08 Apr 2013 16:21:32 GMT) ?
Réponse de Travis Bell
le 8 avril 2013 à 12h37
Nope, probably not but it all depends on your usage and desired interval to check for updates. At the end of the day, conditional GETs benefit everyone since they:
Is it going to be a dramatic difference? Probably not, but it's still good design.
Réponse de Dominic
le 8 avril 2013 à 12h49
Implementations is quite simple so I think I will use version check. Can you elaborate why Etag is used and not last modified date? It looks to me like a date would be be human friendly that Etag. Storing Etag is a database has only one purpose, last modified date could have other uses too.
Réponse de Travis Bell
le 8 avril 2013 à 13h05
Currently,
Last-Modified
is not maintained on our end. Things like language and locale params all play into the data that gets served which is used to generate the unique ETag. This is not true forLast-Modified
.