feedbin / feedbin-api

Feedbin API Documentation
349 stars 26 forks source link

Last-Modified header is not returned when using /v2/feeds/{feed_id}/entries.json #61

Closed harshpandit98 closed 3 years ago

harshpandit98 commented 3 years ago

Hello, we have a scenario where entries are obtained from feeds. Those feed_ids are obtained with /v2/taggings.json endpoint.

We would like to sense if feed is modified. There's http caching section in read me. I would like to use it with /v2/feeds/{feed_id}/entries.json. I guess for that Etag and Last-Modified headers are required to be pass with request.

Etag is present, Last-Modified tag is unrepresent. I was going through issues and read Etag could be used. So i tested with it. Below is curl log:

Command: curl -v -u 'usr:pass' https://api.feedbin.com/v2/feeds/72/entries.json?per_page=2

Curl trace:

*  expire date: Dec 18 05:50:54 2021 GMT
> GET /v2/feeds/72/entries.json?per_page=2 HTTP/1.1
> Host: api.feedbin.com
> User-Agent: curl/7.76.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< date: Sun, 26 Sep 2021 08:32:09 GMT
< content-type: application/json; charset=utf-8
< content-length: 7853
< vary: Accept-Encoding
< x-frame-options: SAMEORIGIN
< x-xss-protection: 1; mode=block
< x-content-type-options: nosniff
< x-download-options: noopen
< x-permitted-cross-domain-policies: none
< referrer-policy: strict-origin-when-cross-origin
< x-feedbin-record-count: 31115
< links: <https://api.feedbin.com/v2/feeds/72/entries.json?page=2&per_page=2>; rel="next", <https://api.feedbin.com/v2/feeds/72/entries.json?page=15558&per_page=2>; rel="last"
< etag: W/"035caf23710b026610ecb542700fde3b"
< cache-control: max-age=0, private, must-revalidate
< x-runtime: 0.078605
< strict-transport-security: max-age=63072000
< server: Feedbin
< 
[{"id":3314942351,"feed_id":72,"title":"The 2022 Kia Carnival is a handsome minivan, but it needs a hybrid option","author":"Jonathan M. Gitlin","summary":"Kia has replaced the Sedona minivan with the Carnival, new for model year 2022. [credit: Jonathan Gitlin ] 

Response header Etag: 035caf23710b026610ecb542700fde3b

I tried another request with the above Etag. However, the results are similar. And returned Etag is identical to previous response.

Command with If-None-Match header: curl -v -u 'usr:pass --header 'If-None-Match:035caf23710b026610ecb542700fde3b' https://api.feedbin.com/v2/feeds/72/entries.json?per_page=2

Curl trace:

> GET /v2/feeds/72/entries.json?per_page=2 HTTP/1.1
> Host: api.feedbin.com
> User-Agent: curl/7.76.1
> Accept: */*
> If-None-Match:"035caf23710b026610ecb542700fde3b"
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< date: Sun, 26 Sep 2021 08:54:04 GMT
< content-type: application/json; charset=utf-8
< content-length: 7853
< vary: Accept-Encoding
< x-frame-options: SAMEORIGIN
< x-xss-protection: 1; mode=block
< x-content-type-options: nosniff
< x-download-options: noopen
< x-permitted-cross-domain-policies: none
< referrer-policy: strict-origin-when-cross-origin
< x-feedbin-record-count: 31115
< links: <https://api.feedbin.com/v2/feeds/72/entries.json?page=2&per_page=2>; rel="next", <https://api.feedbin.com/v2/feeds/72/entries.json?page=15558&per_page=2>; rel="last"
< etag: W/"035caf23710b026610ecb542700fde3b"
< cache-control: max-age=0, private, must-revalidate
< x-runtime: 0.066853
< strict-transport-security: max-age=63072000
< server: Feedbin
< 
[{"id":3314942351,"feed_id":72,"title":"The 2022 Kia Carnival is a handsome minivan, but it needs a hybrid option","author":"Jonathan M. Gitlin","summary":"Kia has replaced the Sedona minivan with the Carnival, new for model year 2022. [credit: Jonathan Gitlin ] I'm not shy about my affection for minivans. And so, despite having no kids and still being in the middle of a pandemic that makes it dangerous to","content":"\u003cdiv

Please point out important issue / pull thread in case I have missed out on or if there's error in command. If details are incomplete, please let me know. thanks

I would like to know if http caching could be used with said endpoint. I'm aware of since parameter. But in that case, we will have to persist the previous stamp for since parameter and re-do the request at the intervals of say 5 minutes or 15 minutes.

Thanks

benubois commented 3 years ago

Hi @harshpandit98,

The etag is: W/"035caf23710b026610ecb542700fde3b"

It looks like you’re only sending a portion of it. Try sending the whole etag:

--header 'If-None-Match: W/"035caf23710b026610ecb542700fde3b"'

Thanks!

harshpandit98 commented 3 years ago

Hello @benubois thanks for the response and insight. Much appreciated.

W/ is for case-insensitivity. I tested it. Works like a charm.

Curl command: curl -v -u 'usr:pass' --header 'If-None-Match: W/"547022ab111c5cfb4713052cea97993c"' https://api.feedbin.com/v2/feeds/72/entries.json\?per_page\=2

Curl trace:

> GET /v2/feeds/72/entries.json?per_page=2 HTTP/1.1
> Host: api.feedbin.com
> User-Agent: curl/7.76.1
> Accept: */*
> If-None-Match: W/"547022ab111c5cfb4713052cea97993c"
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 304 Not Modified
< date: Mon, 27 Sep 2021 06:22:13 GMT
< x-frame-options: SAMEORIGIN
< x-xss-protection: 1; mode=block
< x-content-type-options: nosniff

Have a wonderful day.

Thanks!