0

Could anyone explain me why "If modified-Since" doesn't work in my http client...?

I check what I send in httpbin.org:

{
"url": "http://www.httpbin.org/get",
"headers": {
"Content-Length": "",
"Connection": "keep-alive",
"Accept": "*/*",
"Host": "www.httpbin.org",
"If-Modified-Since": "Mon, 12 Nov 2012 18:00:00 GMT",
"Content-Type": ""
},
"args": {    },
"origin": "89.70.183.105"
}

But I still get every file. "If-modified-since" simply doesn't work. Maybe it's not implemented in servers? If so, could anyone point me server that has implemented this header? Or explain what I'm doing wrong?

Thanks for help

abelenky
  • 63,815
  • 23
  • 109
  • 159
user1814605
  • 41
  • 1
  • 5
  • Well, we can't explain why it doesn't work without knowing what your client is :) – Lightness Races in Orbit Nov 12 '12 at 18:25
  • Does it matter? I write my own http client. Maybe I'm wrong but I think that it's only important what I really send to servers. I think it doesn't matter how it is implemented in my code... Am I right? – user1814605 Nov 12 '12 at 18:40
  • We cannot see your definition of "simply doesn't work" for ourselves -- you could be handling the response incorrectly. – Lightness Races in Orbit Nov 12 '12 at 19:27
  • Voting to close as a typo error because @user1814605 says "In my code I wrote "If-Modified_Since" instead of "If-Modified-Since"..." – Piran Dec 27 '18 at 11:24

2 Answers2

0

Your request looks correct to me, so I'm guessing that the server you are requesting from is not configured to return 304 (Not Modified).

I note that your request does not make it clear what kind of file you're trying to retrieve, but it is typical that servers do not return Not Modified messages on dynamic content (such as PHP, ASPX, etc), as the server doesn't know if the content has changed or not, since it cannot predict the output of the script.

abelenky
  • 63,815
  • 23
  • 109
  • 159
  • I don't mean one file or one server. I'm trying to check my http client and I can't find one case when this header works. :( – user1814605 Nov 12 '12 at 18:23
  • For example: http://www.astrojawil.pl/ .... When I check in Mozilla Firefox (using Live Http headers tool). This returns: Last-Modified: Fri, 30 Mar 2012 04:59:22 GMT.... And I still can get this page from my http client where I have set: "If-Modified-Since": "Mon, 12 Nov 2012 18:00:00 GMT".... ;( – user1814605 Nov 12 '12 at 18:35
  • It is possible that you misunderstand what the response to an `If-Modified-Since` header is supposed to be. I recommend editing your question to explain in detail what you expect to see in the response, and what you are actually seeing. – abelenky Nov 12 '12 at 19:00
  • OK, abelenky. I think that "If-Modified-Since" header should work like that: I try to GET file (for example txt or jpeg) from some server.... I make request GET with "If-modified-Since"... 1) If file that I want to get has "Last Modified" date after my date (in If-Modified-Since) I should get this file. If this file has "Last Modified" date BEFORE date in my "If-Modified-Since" - I shouldn't get that file and server should return error code 304... – user1814605 Nov 12 '12 at 19:13
  • A minor nit is that 304 is NOT an error-code. It is a success code that indicates, "You should already have this file in your local cache. Use that copy, and don't make me send you a new copy." Hence, after a 304, you should still have the data (retrieved from cache), and all pathways should see "success", not "error". – abelenky Nov 12 '12 at 19:31
0

Thank You for Your help!

You can't believe where I had a mistake... In my code I wrote "If-Modified_Since" instead of "If-Modified-Since"...

It's very weird, because httpbin.org/get tell me that I send "If-Modified-Since"...(!!!)

But when my request is for example: "zbcdefghijk" - httpbin.org/get shows me that I sent exactly that header (that not exist of course).

I spent 7 hours looking for my mistake. ;( It was difficult to find because I too much trusted httpbin.org. :(((((

user1814605
  • 41
  • 1
  • 5
  • 2
    This is why you should copy-paste your **EXACT** code into your question. Any of us would've spotted that mistake for you. But the mistake isn't present in your question (above). – abelenky Nov 13 '12 at 18:54