How to get a remote-file's mtime before downloading it in Ruby?

后端 未结 3 461
名媛妹妹
名媛妹妹 2021-02-06 14:57

I have the below code, which simply downloads a file and saves it. I want to run it every 30 seconds and check if the remote-file\'s mtime has changed and download it if it has.

3条回答
  •  既然无缘
    2021-02-06 15:17

    You can try to send the If-Modified-Since header with a correctly formatted date.

    If the server supports it, it can answer just with a 304 Not Modified status (without any content) or the full content if the file has been modified.

提交回复
热议问题