在网络应用程序中,如何预加载一组任意文件以便在浏览它们时更快地查看它们?
假设我有一个包含两个窗格的 .NET Web 应用程序。一个窗格是一个能够显示各种大型文件类型的查看器。另一个窗格包含任意文件列表,例如 file1.docx、file2.xlsx、file3.pptx、file4.txt、file5.doc、file6.htm、file7.zxz、file8.exe 等。
用户可以选择列表中的任何文件,并在选择更改时将其显示在相邻窗格中(可能是通过客户端 JavaScript)。假设用户选择了某个文件,例如 file1.docx,是否有办法在用户查看 file1.docx 时预取/预加载列表中的一些文件,例如 file2.xlsx 和 file3.pptx?
如果这可以通过类似 Ajax 的异步调用在后台完成,那么对于按顺序从一个文件转到另一个文件的用户来说,应用程序将显得更快。我假设预取调用可能足够聪明,不会尝试请求无法查看的文件,例如 exe 文件。
任何帮助或例子将不胜感激。
Suppose I have a .NET web application that contains two panes. One pane is a viewer capable of displaying a variety of large file types. The other pane contains an arbitrary list of files, e.g. file1.docx, file2.xlsx, file3.pptx, file4.txt, file5.doc, file6.htm, file7.zxz, file8.exe etc.
The user is capable of selecting any file in the list and displaying it in the adjacent pane when the selection changes, presumably via client-side Javascript. Given the user has selected some file, e.g. file1.docx, is there a way to prefetch/preload some number of files in the list, e.g. file2.xlsx and file3.pptx while the user is viewing file1.docx?
If this could be done in the background with an asynchronous Ajax-like call, it would make the application appear faster for users who went from file to file in sequence. I am assuming that the prefetch call could be smart enough not to attempt to request files that could not be viewed, e.g. exe files.
Any help or examples would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用隐藏的 iframe 在第一次单击后加载后续文档。在允许点击事件之前,使用插件检测脚本检查文件扩展名支持。如果您想预渲染,请使用每个浏览器的预取 API:
Use hidden iframes to load subsequent documents after the first click. Use a plugin detection script to check file extension support prior to allowing the click event. If you want to prerender, then use each browsers prefetch API: