OpenListTeam / OpenListTeam/OpenList-Frontend
[BUG] token在浏览器中的缓存问题
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 100
- Forks
- 240
- Avg merge
- 22h 42m
- Merged PRs (30d)
- 17
Description
Please confirm the following
-
I have read and agree to AGPL-3.0 Section 15 .
The program is provided "as is" without any warranties; you bear all risks of using it. -
I have read and agree to AGPL-3.0 Section 16 .
The copyright holders and distributors are not liable for any damages resulting from the use or inability to use the program. -
I confirm my description is clear, polite, helps developers quickly locate the issue, and complies with community rules.
-
I have read the OpenList documentation.
-
I confirm there are no duplicate issues or discussions.
-
I confirm this is an
OpenListissue, not caused by other reasons (such as network, dependencies, or operation). -
I believe this issue must be handled by
OpenListand not by a third party. -
I confirm this issue is not fixed in the latest version.
OpenList Version (required)
v4.1.1
Storage Driver Used (required)
Degoo
Bug Description (required)
当在后端出现429错误时,在存储中删除(此时应该把这个相关的所有数据都删除,包括缓存的token信息),再重新添加,任然会出现这个错误
意为着,并没有进行重新登陆的操作(重新通过登陆来缓存新的token信息),而是使用了浏览器或者数据库中的缓存信息,因为token已经失效,所以会报错
精准缓存清理方案
- 问题分析
- Clear-Site-Data 头会清除整个站点的缓存和存储,影响所有存储
- 我们只想清除特定存储相关的缓存数据
- 更好的解决方案
方案A:响应数据中包含清理指令
{
"code": 200,
"message": "success",
"data": {
"deleted_storage_id": 123,
"clear_cache": {
"storage_key": "storage_123",
"driver_type": "Degoo"
}
}
}
方案B:前端主动清理特定存储缓存
在删除存储的API响应中,前端JavaScript可以:
// 删除存储成功后执行
function clearStorageCache(storageId, driverType) {
// 清除localStorage中特定存储的数据
const keys = Object.keys(localStorage);
keys.forEach(key => {
if (key.includes(storage_${storageId}) ||
key.includes(${driverType}_token) ||
key.includes(degoo_)) {
localStorage.removeItem(key);
}
});
// 清除sessionStorage
const sessionKeys = Object.keys(sessionStorage);
sessionKeys.forEach(key => {
if (key.includes(`storage_${storageId}`)) {
sessionStorage.removeItem(key);
}
});
}
方案C:服务端主动通知前端
使用WebSocket或Server-Sent Events通知前端清理特定缓存:
{
"event": "storage_deleted",
"data": {
"storage_id": 123,
"clear_cache_keys": ["degoo_token_123", "storage_123_config"]
}
}
🔍 最佳实践建议
- 后端响应增强 - 在删除成功响应中包含需要清理的缓存key信息
- 前端精准清理 - JavaScript根据响应信息只清理相关的缓存项
- Token隔离 - 将不同存储的token用storage_id区分存储
Configuration File Content (required)
storage.go
Logs (optional)
No response
Reproduction Link (optional)
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing storage.go and the frontend flow for deleting and re-adding a Degoo storage, focusing on where its token is cached. Reproduce the 429 scenario and verify that deleting a storage removes only its related browser or database cache, so re-adding it does not reuse the expired token.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- authentication, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100