Skip to content

Conversation

@jenfonro
Copy link
Contributor

@jenfonro jenfonro commented Feb 9, 2026

Description / 描述

下载本地存储驱动的文件时禁用浏览器缓存的版本

改动会致使每次点击下载都会请求服务器,可能需要考虑增加设置来让用户自己决定?

Motivation and Context / 背景

Closes #XXXX

Relates to #XXXX

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).
    我已相应更新了相关仓库(若适用)。

Copy link
Member

@xrgzs xrgzs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这么改的话,那CDN不就没缓存了吗?

@jenfonro
Copy link
Contributor Author

jenfonro commented Feb 9, 2026

这么改的话,那CDN不就没缓存了吗?

是的,所以我觉得应该是要加个开关,

因为获取最新的文件与cdn缓存好像并没有很好的同时解决办法,所以先发上来问问大佬们的意见

@jyxjjj
Copy link
Member

jyxjjj commented Feb 11, 2026

Pragma 已被弃用
ExpiresMaxAge/SMaxAge 存在时将被忽略

要修改这个逻辑,首先要明确这么做的原因。

因为会有两个方案:
一、原生方案,没有绕过任何东西,完全符合标准的做法。
MustRevalidate存在时,浏览器应在缓存过期后请求是否存在变更。
Conditional Request会存在:
If-Modified-Since: <Last Response Last-Modified>
If-None-Match: <Last Response ETag>
服务端应检查并返回200以允许文件被下载,或304并返回空文件体。
二、通过随机、时间戳作为查询参数绕过缓存。
https://example.com/some/file.ext?_t={ts}

以OpenList的逻辑来说,本地驱动必然存在修改时间,Stat获取后直接扔进Last-Modified,并将MaxAge SMaxAge均设置为1秒、策略设置为public,也是合理做法。浏览器每次发送If-Modified-Since时,都Stat一次,返回文件内容或304响应。
至于1秒是否足够,还可以通过要求浏览器发送 (1) (2) 并通过浏览器发送的 RTTDownlink 来判断。

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.

3 participants