Curl If-None-Match vs If-Modified-Since
Curl可以透过检查Etag
来确认档案是否修改过
如果没有则回应304
# curl -I http://192.168.1.168/image/A.jpg
HTTP/1.1 200 OK
Date: Fri, 14 Nov 2014 01:37:28 GMT
Server: Apache/2.2.22 (Ubuntu)
Last-Modified: Wed, 12 Nov 2014 02:35:31 GMT
ETag: "5a-4213-507a03fda82c0"
Accept-Ranges: bytes
Content-Length: 16915
Content-Type: image/jpeg
# curl -I http://192.168.1.168/image/A.jpg --header 'If-None-Match: "5a-4213-507a03fda82c0"'
HTTP/1.1 304 Not Modified
Date: Fri, 14 Nov 2014 01:38:29 GMT
Server: Apache/2.2.22 (Ubuntu)
ETag: "5a-4213-507a03fda82c0"
http://wpcertification.blogspot.tw/2010/08/how-to-enable-etag-in-apache-http.html
Etag在Apache上是由Inode + mtime + Size来产生的
Curl也可以检查Last-Modified
来确认档案是否修改过
#curl -I http://192.168.1.168/image/A.jpg -H 'If-Modified-Since: Wed, 12 Nov 2014 02:35:31 GMT'
HTTP/1.1 304 Not Modified
Date: Fri, 14 Nov 2014 01:44:06 GMT
Server: Apache/2.2.22 (Ubuntu)
ETag: "5a-4213-507a03fda82c0"
来确认档案是否修改过
如果没有则回应304
# curl -I http://192.168.1.168/image/A.jpg
HTTP/1.1 200 OK
Date: Fri, 14 Nov 2014 01:37:28 GMT
Server: Apache/2.2.22 (Ubuntu)
Last-Modified: Wed, 12 Nov 2014 02:35:31 GMT
ETag: "5a-4213-507a03fda82c0"
Accept-Ranges: bytes
Content-Length: 16915
Content-Type: image/jpeg
# curl -I http://192.168.1.168/image/A.jpg --header 'If-None-Match: "5a-4213-507a03fda82c0"'
HTTP/1.1 304 Not Modified
Date: Fri, 14 Nov 2014 01:38:29 GMT
Server: Apache/2.2.22 (Ubuntu)
ETag: "5a-4213-507a03fda82c0"
http://wpcertification.blogspot.tw/2010/08/how-to-enable-etag-in-apache-http.html
Etag在Apache上是由Inode + mtime + Size来产生的
Curl也可以检查Last-Modified
来确认档案是否修改过
#curl -I http://192.168.1.168/image/A.jpg -H 'If-Modified-Since: Wed, 12 Nov 2014 02:35:31 GMT'
HTTP/1.1 304 Not Modified
Date: Fri, 14 Nov 2014 01:44:06 GMT
Server: Apache/2.2.22 (Ubuntu)
ETag: "5a-4213-507a03fda82c0"