【问题标题】:Image caching at server side服务器端的图像缓存
【发布时间】:2023-04-08 18:54:02
【问题描述】:

对于在 java/spring 中创建的产品目录 web 应用程序,它从第三方 web 服务获取产品图像,在服务器端缓存图像的好策略是什么?

谢谢。

【问题讨论】:

    标签: image caching server-side


    【解决方案1】:

    让您的网站创建指向本地托管页面的 IMG 引用。此页面将执行以下操作:

    if (the requested image does not exist in the local cache) {
        go to the third party site and save it to the local cache
    }
    serve the image from the local cache
    

    根据第三方网站上图像可能更改的频率,您可能需要添加一个定期删除超过 X 天的图像的 cron 作业。

    【讨论】:

    • 谢谢。我们确实将图像 url 保存在 mongodb 中。但目前从 3rd 方服务获取实际图像。你是对的,最简单的缓存就像你提到的那样。
    猜你喜欢
    • 2014-05-12
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 2016-01-24
    • 1970-01-01
    • 2014-12-02
    • 2012-09-29
    相关资源
    最近更新 更多