md5_file 是否下载从中获取校验和的文件?
如果我使用 md5_file 在 PHP 中获取远程文件的校验和,它是下载文件并获取校验和还是从远程服务器请求校验和?基本上我想弄清楚的是,在重新下载文件之前对文件进行 MD5 检查以查看它是否已更改是否需要更少的带宽,但是如果 md5_file 将文件下载到临时位置,那么检查一下,我还是直接下载文件吧?
If I use md5_file to get the checksum of a remote file in PHP, does it download the file and them get the checksum or does it request the checksum from the remote server? Basically what I'm trying to figure out is if it is less bandwidth to do a MD5 check on a file to see if it has changed before I re-download the file, but if md5_file downloads the file to a temp location then does the check, I might as well just download the file straight-up anyway, right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
扩展 Wodins 答案:如果您对远程文件发出
HEAD
请求,则带宽会减少。网络服务器响应通常包含 ETag 标头形式的哈希值。使用:参见http://php.net/manual/en/function.get- headers.php 为例。
Expanding on Wodins answer: It's less bandwidth if you issue a
HEAD
request on the remote file. The webserver response usually includes a hash in the form of anETag
header. Use:See http://php.net/manual/en/function.get-headers.php for examples.
是的,它必须如此。您可能应该做的是“如果修改后”请求,该请求仅在时间戳比您指定的时间新时才会向您发送文件。我不知道你是如何用 php 做到这一点的。
It would have to, yes. What you should probably do instead is an "if modified since" request that will only send you the file if the timestamp is newer than the time you specify. I don't know how you do that with php though.
是的,它实际上下载了文件。
Yes, it actually downloads the file.