背景与价值

在风控或登出时清理站点数据可降低残留风险。Clear-Site-Data提供标准化的清理能力,保障会话与隐私安全。

统一规范

  • 清理维度:"cookies", "storage", "cache"。
  • 条件触发:风控、登出或高风险处置时启用。
  • 搭配:配合 Set-Cookie 清除会话标识。

核心实现

头设置

type Res = { setHeader: (k: string, v: string) => void; end: (b?: string) => void }

function clearSiteData(res: Res, cookies = true, storage = true, cache = true) {
  const items: string[] = []
  if (cookies) items.push('"cookies"')
  if (storage) items.push('"storage"')
  if (cache) items.push('"cache"')
  res.setHeader('Clear-Site-Data', items.join(', '))
}

落地建议

  • 在登出与高风险处置中统一下发清理头并清除会话Cookie,提升安全。

验证清单

  • 是否下发包含必要维度的Clear-Site-Data;会话是否同步清除。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部