How to avoid occasional corrupted downloads

久未见 提交于 2019-12-14 00:26:19

问题


My website hosts a msi file that users need to download. There is nothing special about the file. It lives in a directory on the webserver with a regular HREF pointing to it that users click on. Occasionally a user will complain that they can't open the msi file because Windows Installer claims the file is corrupt. Redownloading the file doesn't help. I end up emailing the file as an attachment which usually works.

My guess is that the file is either corrupted in the user's browser cache or perhaps an intermediary proxy's cache which the user goes through.

Why does this happen? Is there a technique / best practice that will minimize chances of corruption or, perhaps make sure users will get a fresh copy of the file if it does get corrupted during download?


回答1:


Well if the cause is really just the cache, then I think you could just rename the file before having them download it again. This would work for any proxies too.

Edit: Also, I believe most browsers won't cache pages unless the Get and Post parameters remain the same. The same probably applies to any URL in general. Try adding a unique get (or post) parameter to the end of the URL of each download. You could use the current time, or a random number, etc. Rather than a hyperlink, you could have a button that, when clicked, submits a form with a unique parameter to the download URL.




回答2:


My advice would be:

  1. Recommend users avoiding IE (especially the older versions), because of truncated downloads, cache pollution...
  2. Advice user to clear the cache before re-downloading the files.
  3. Host the file on an FTP instead of HTTP
  4. Provide MD5 checksum for user to verify the download.


来源:https://stackoverflow.com/questions/3208686/how-to-avoid-occasional-corrupted-downloads

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!