Skip to content

Conversation

@bitxeno
Copy link

@bitxeno bitxeno commented Dec 8, 2025

Description / 描述

为压缩包中的图片类型添加Cache-Control头部,避免直接预览压缩包中的图片时,浏览器会多次请求加载

Motivation and Context / 背景

前端添加直接预览压缩包文件功能,预览图片时没有缓存功能,会导致浏览器多次请求加载

How Has This Been Tested? / 测试

本地测试

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

@jyxjjj
Copy link
Member

jyxjjj commented Dec 8, 2025

不被接受,认为应该从Nginx与CDN层处理。业务不应直接暴露端口。

@OpenListTeam OpenListTeam locked and limited conversation to collaborators Dec 8, 2025
@OpenListTeam OpenListTeam unlocked this conversation Dec 8, 2025
@jyxjjj jyxjjj closed this Dec 8, 2025
@bitxeno
Copy link
Author

bitxeno commented Dec 8, 2025

@jyxjjj 压缩包文件的路径是放query中,可能用户不容易设置,是只能设置etaglast-modified头部吗?非压缩包图片是用这两个,不过压缩包文件拿不了文件的修改时间

@jyxjjj
Copy link
Member

jyxjjj commented Dec 8, 2025

具体方案再等团队讨论一下吧,因为不仅是图片存在这个情况。
而且我认为通过文件类型缓存是合理的做法。
暂时还是给你关闭,如果团队决定合并可以重新打开的。
我的意见是诸如

map $upstream_http_content_type $cache_control {
    default        "no-cache";
    "text/html"    "no-store";
    "image/png"    "max-age=86400";
}

server {
    location / {
        proxy_pass http://backend;
        add_header Cache-Control $cache_control;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants