有没有办法在客户端计算机中永久缓存文件?

Is there a way to cache files in client computer permanently?

我有一个网络应用程序,它提供扫描的旧文档的图像及其成绩单,图像很多,大约 5 GB,客户需要定期浏览它们。

我需要一个在客户端缓存图像的解决方案,因为图像是不可变的,它们应该只从服务器获取一次。

这将允许您在客户端计算机上缓存大量 GB。我看不出这将如何长期有效(用户清除缓存、更改浏览器、计算机等)。这听起来像是一个糟糕的问题解决方案。

话虽这么说,你应该看看 IndexedDB:

IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data. While Web Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solution.

备注:

  • This feature is available in Web Workers.
  • IndexedDB API is powerful, but may seem too complicated for simple cases. If you'd prefer a simple API, try libraries such as localForage, dexie.js, ZangoDB, PouchDB, and JsStore that make IndexedDB more programmer-friendly.