I am doing something like this: if an image is cached on user's computer and its timestamp is the same as the one on the server, then display the cached version; otherwise, do NOT load the image from the server.

我这样做:如果图像缓存在用户的计算机上,并且其时间戳与服务器上的时间戳相同,则显示缓存版本;否则,请勿从服务器加载图像。

I guess maybe JavaScript can do this, so I tagged this post as javascript. If it is improper, please help me to re-tag it.

我想也许JavaScript可以做到这一点,所以我将这篇文章标记为javascript。如果不合适,请帮我重新标记。

Edit: Here I give more details about what I am going to implement. I am working on something like a web-based file explorer, where thumbnails are loaded only if the user click on a "view thumbnail" button beside each image. If a thumbnail is already cached, use the cached version; otherwise, show a generic image icon.

编辑:在这里,我提供了有关我将要实施的内容的更多详细信息。我正在开发类似于基于Web的文件浏览器,只有当用户单击每个图像旁边的“视图缩略图”按钮时才会加载缩略图。如果已经缓存了缩略图,请使用缓存版本;否则,显示通用图像图标。

5 个解决方案

#1


0

A browser can send the "If-Modified-Since" and "ETag" headers to indicate to the server that it does have a version of a resource. Check the W3 caching rules regarding these headers.

浏览器可以发送“If-Modified-Since”和“ETag”标头,以向服务器指示它确实具有资源版本。检查有关这些标头的W3缓存规则。

You could query for those headers on the server, sending back the generic icon if not found, and a "304 Not Modified" response if found.

您可以在服务器上查询这些标头,如果找不到,则发回通用图标,如果找到,则返回“304 Not Modified”响应。

更多相关文章

  1. Javascript来自数据库的图像上的图像映射
  2. python 简单图像处理(2) 镜像
  3. caffe python批量抽取图像特征
  4. 在Python中显示来自控制台的图像
  5. Python为8bit深度图像应用color map
  6. 每次部署站点时,如何使用Google App Engine清除内存缓存?
  7. Tensorflow:恢复图形和模型,然后在单个图像上运行评估
  8. 在需要缓存的时候,谨慎使用python的负下标
  9. python的PIL绘制多行文本的图像。

随机推荐

  1. 8 个给前端的顶级 VS Code 扩展插件 [每
  2. 在 JavaScript 中优雅的提取循环内的数据
  3. 必须要会的 50 个React 面试题(上)[每日前
  4. C语言的for循环以及一些练习
  5. 必须要会的 50 个React 面试题(下)[每日前
  6. 今天记的笔记
  7. 2021.1.19
  8. JavaScript 的未来:它还少些什么? [每日前
  9. C语言学习心得(八)
  10. 爬取6271家死亡公司数据,看十年创业公司消