Is the /catalog/titles/index is updated at a certain time of the day? It would be nice to know if so, so Instantwatcher can minimize the delay between information becoming available and information appearing on its webpages.
This is a good scenario for using etags with the If-None-Match directive:
• If etag value different then file is downloaded
• If eTag value matched, then I get HTTP/1.1 304 Not Modified response.
Hi Michael - I tried take your advice and do a HEAD request just to get the headers (esp the etag) for /catalog/titles/index. But this doesn't seem to be permitted. I'm passing all my authentication creds in this head request.
You just need to do a GET passing the etag from a previously successful GET within an if-match header. If the etag hasn't changed you'll get a 412 status, otherwise the latest version of the index will download.
OK I downloaded the titles index again and got the latest ETag header:
Etag: "60002-13b96576-775e2300"-gzip
My question now is how to send this Etag in the next request to /catalog/titles/index. When I try to fetch the catalog/titles/index again, should I send the If-None-Match header with this ETag?
Is the /catalog/titles/index is updated at a certain time of the day? It would be nice to know if so, so Instantwatcher can minimize the delay between information becoming available and information appearing on its webpages.
Message edited by dhchoi 2 years ago
Doron – 2 years ago
Usually one would use HTTP HEAD requests to look at date changes, but I don't think that will work with the API signed calls.
Perhaps some xml file one can poll say hourly to see if a new version is up?
Michael Hart – 2 years ago
This is a good scenario for using etags with the If-None-Match directive:
• If etag value different then file is downloaded
• If eTag value matched, then I get HTTP/1.1 304 Not Modified response.
dhchoi – 2 years ago
Thanks for the suggestion
dhchoi – 2 years ago
Hi Michael - I tried take your advice and do a HEAD request just to get the headers (esp the etag) for /catalog/titles/index. But this doesn't seem to be permitted. I'm passing all my authentication creds in this head request.
This is the response I get
HTTP/1.1 596
X-Lighty-Magnet-Uri-Path: /catalog/titles/index
X-Mashery-Error-Code: ERR_596_SERVICE_NOT_FOUND
Content-Type: text/xml
Accept-Ranges: bytes
Content-Length: 30
Date: Fri, 27 Nov 2009 22:04:37 GMT
Server: Mashery Proxy
Has anyone else successfully performed a HEAD request on /catalog/titles/index?
JR Conlin – 2 years ago
Hmm... Looks like a bug on our side. We'll work on it and let you know when it's available.
Sorry for the trouble.
Michael Hart – 2 years ago
You just need to do a GET passing the etag from a previously successful GET within an if-match header. If the etag hasn't changed you'll get a 412 status, otherwise the latest version of the index will download.
dhchoi – 2 years ago
OK I downloaded the titles index again and got the latest ETag header:
Etag: "60002-13b96576-775e2300"-gzip
My question now is how to send this Etag in the next request to /catalog/titles/index. When I try to fetch the catalog/titles/index again, should I send the If-None-Match header with this ETag?
If-None-Match: "60002-13b96576-775e2300"-gzip
dhchoi – 2 years ago
That worked. Thanks.
dhchoi – 2 years ago
But maybe I should note I got a 304 Not Modified, not a 412. That seems to be right.
Hans Granqvist – 2 years ago
304 is correct for if-non-match mismatch, 412 is correct for if-match mismatch. (See RFC 2068.)
Michael Hart – 2 years ago
Sorry for the confusion. Yes, if-none-match is the right directive for cache control and the 304 status is what to look for.
dhchoi – 2 years ago
Thanks for the help.
Doron – 2 years ago
Has anyone been able to just fetch the headers?
Using curl on the full catalog url I get:
HTTP/1.1 596
X-Lighty-Magnet-Uri-Path: /catalog/titles/index
X-Mashery-Error-Code: ERR_596_SERVICE_NOT_FOUND
Content-Type: text/xml
Accept-Ranges: bytes
Content-Length: 30
Date: Sat, 05 Dec 2009 09:42:15 GMT
Server: Mashery Proxy
Michael Hart – 2 years ago
The API doesn't support HEAD requests. If you're trying to use etags, read above for how to do that without a HEAD request.