I'm trying to check if a file has been modified after a given date. I found this I'm trying to use Java's HttpURLConnection to do a "conditional get", but I never get a 304 status code. which seemed like what I needed. But if I try:
URLConnection connection = new URL("http://cdn3.sstatic.net/stackoverflow/img/favicon.ico").openConnection();
connection.setRequestProperty("If-Modified-Since", "Wed, 06 Oct 2010 02:53:46 GMT");
System.out.println(connection.getHeaderFields());
The output is:
{null=[HTTP/1.1 200 OK], ETag=["087588e2bb5cd1:0"],
Date=[Wed, 28 Nov 2012 12:39:31 GMT], Content-Length=[1150],
Last-Modified=[Sun, 28 Oct 2012 16:44:54 GMT], Accept-Ranges=[bytes],
Connection=[keep-alive], Content-Type=[image/x-icon], X-Cache=[HIT],
Server=[NetDNA-cache/2.2], Cache-Control=[max-age=604800]}
Edit
I've tried today's date but still doesn't return 304.
Wed, 28 Nov 2012 12:59:56 GMT
It should return 304 but as you can see it doesn't, any help is appropriated.
The file has been modified. Change your If-Modified-Since
header to something after the Last-Modified
result.
I tried it (with curl) and this CDN seems to have trouble with dates. To get a 304
response to an If-Modified-Since
request, you need to provide the exact Last-Modified
date (Sun, 28 Oct 2012 16:44:54 GMT here). Needless to say this is evil behaviour from this CDN.