If-Modified-Since and Last-Modified for binaries (speaker images)
chrissearle opened this issue · 5 comments
We're updating the iOS app to prevent it downloading speaker images every time you open a session.
To do so we're now sending the If-Modified-Since header.
This is working fine for gravatar images (48 speakers in 2014) but not for EMS images (111 speakers in 2014).
Nor does EMS send the Last-Modified header - so I have no date to check against.
Oddly - EMS seems to respect If-Modified-Since for non-images - but for images it just returns a 200 OK and the image instead of 304 Not Modified.
Some sample URLS.
- http://javazone.no/ems/server/binary/fd901e10-b4fc-4864-9def-a9e75900b324?size=thumb
- http://javazone.no/ems/server/binary/f92f274b-4399-4a08-b464-30192f86cc79?size=thumb
- http://javazone.no/ems/server/binary/03a0d126-f925-4dbc-b4f8-de110b6676a7?size=thumb
- http://javazone.no/ems/server/binary/e737ec8a-74de-491a-9f0f-a4930dcf97e5?size=thumb
- http://javazone.no/ems/server/binary/9f0f547e-8f00-4690-9722-53f1f49d6ebd?size=thumb
- http://javazone.no/ems/server/binary/3b91ecc0-8ce4-466f-a8a6-b725ef5066ab?size=thumb
- http://javazone.no/ems/server/binary/862db91a-4bfd-4dfa-a530-cd68c33c0535?size=thumb
Relates to javaBin/ems-ios#129
Something odd.
Let's say I already have an image - and it has a last modified of Wed, 18 Jun 2014 10:19:39 GMT
Then I request again - this time with If-Modified-Since
GET /ems/server/binary/fb08ed18-e50c-4518-af87-bf699dcc7024?size=thumb HTTP/1.1
Host: javazone.no
Accept: */*
If-Modified-Since: Wed, 18 Jun 2014 10:19:39 GMT
User-Agent: JavaZone/22 CFNetwork/711.1.12 Darwin/14.1.0
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive
Then what I expect is 304 Not Modified - but what I get is:
HTTP/1.1 200 OK
Server: nginx/1.1.19
Date: Wed, 04 Mar 2015 09:45:56 GMT
Content-Disposition: attachment; filename="cv-bilde-wendel.jpg"
Content-Length: 13627
Content-Type: image/jpeg
Last-Modified: Wed, 18 Jun 2014 10:19:39 GMT
Via: 1.1 aer01-mda1-dmz-wsa-1.cisco.com:80 (Cisco-WSA/8.5.0-497), 1.1 Application and Content Networking System Software 5.5.31
Connection: Close
So - the last modified info is there - but it's not actually giving the correct response for the request with if-modified-since set?
$ curl "http://javazone.no/ems/server/binary/fb08ed18-e50c-4518-af87-bf699dcc7024?size=thumb" -v > /dev/null
* Hostname was NOT found in DNS cache
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 212.71.237.26...
* Connected to javazone.no (212.71.237.26) port 80 (#0)
> GET /ems/server/binary/fb08ed18-e50c-4518-af87-bf699dcc7024?size=thumb HTTP/1.1
> User-Agent: curl/7.37.1
> Host: javazone.no
> Accept: */*
>
< HTTP/1.1 200 OK
* Server nginx/1.1.19 is not blacklisted
< Server: nginx/1.1.19
< Date: Wed, 04 Mar 2015 14:15:57 GMT
< Content-Type: image/jpeg
< Content-Length: 13627
< Connection: keep-alive
< Last-Modified: Wed, 18 Jun 2014 10:19:39 GMT
< Content-Disposition: attachment; filename="cv-bilde-wendel.jpg"
<
{ [data not shown]
100 13627 100 13627 0 0 155k 0 --:--:-- --:--:-- --:--:-- 156k
* Connection #0 to host javazone.no left intact
[ 3:16PM ] [ maedhros@arya:~/Projects/schibsted/recsys ]
$ curl -H 'If-Modified-Since: Wed, 18 Jun 2014 10:19:39 GMT' "http://javazone.no/ems/server/binary/fb08ed18-e50c-4518-af87-bf699dcc7024?size=thumb" -v > /dev/null
* Hostname was NOT found in DNS cache
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 212.71.237.26...
* Connected to javazone.no (212.71.237.26) port 80 (#0)
> GET /ems/server/binary/fb08ed18-e50c-4518-af87-bf699dcc7024?size=thumb HTTP/1.1
> User-Agent: curl/7.37.1
> Host: javazone.no
> Accept: */*
> If-Modified-Since: Wed, 18 Jun 2014 10:19:39 GMT
>
< HTTP/1.1 304 Not Modified
* Server nginx/1.1.19 is not blacklisted
< Server: nginx/1.1.19
< Date: Wed, 04 Mar 2015 14:16:19 GMT
< Connection: keep-alive
<
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Connection #0 to host javazone.no left intact
OK - weirder than weird.
That output was from wireshark - what it actually observed on the wire - not from the client I was testing.
But - if I use telnet:
~ » telnet javazone.no 80
Trying 212.71.237.26...
Connected to javazone.no.
Escape character is '^]'.
GET /ems/server/binary/fb08ed18-e50c-4518-af87-bf699dcc7024?size=thumb HTTP/1.1
Host: javazone.no
Accept: */*
If-Modified-Since: Wed, 18 Jun 2014 10:19:39 GMT
User-Agent: JavaZone/22 CFNetwork/711.1.12 Darwin/14.1.0
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive
HTTP/1.1 304 Not Modified
Server: nginx/1.1.19
Date: Wed, 04 Mar 2015 15:25:45 GMT
Connection: keep-alive
Note that here I copied and pasted the HTTP conversation above into telnet - and bam - a 304.
So now I just don't know what's going on.
This seems to work for javazone-web-api. Fixed?