http - 当 OPTIONS 方法不可缓存时,为什么要在 Access-Control-Request-Method、ACRH 和 origin 上添加 Vary?
问题描述
我发现了 CORS 的 go implementation,它在每个 CORS 请求中添加了以下标头:
headers.Add("Vary", "Origin")
headers.Add("Vary", "Access-Control-Request-Method")
headers.Add("Vary", "Access-Control-Request-Headers")
https://github.com/rs/cors/blob/f9bce55a4e61e3d1a061993e3453eb9848fcdc4d/cors.go#L269
但据我所知 OPTIONS 方法不可缓存?
那么他们为什么要添加 Vary 标头呢?
解决方案
OPTIONS 方法可以被中间缓存缓存。
例如:
If you want OPTIONS responses to be cached, do the following:(...)
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html
推荐阅读
- amazon-web-services - 通过具有特定角色的 EKSCTL 创建 EKS 集群
- python - Ape 尝试制作密码生成器:“if 语句”和“try & except”函数太难了(Python)
- excel - 如何使用 IFNA,如果 NA 作为文本字符串加上顺序编号,则创建值
- excel - VBA循环要求用户输入新的工作表名称
- java - Java 泛型类型继承
- python - 如何使用 React 为 FastApi 配置 .htaccess
- javascript - 在 Visual Studio Code 中使用 IntelliSense 时 TypeScript React 道具优先级
- javascript - 输出包含 RTL 字符串的日期字符串的有线行为
- ftp-client - Apache Commons-Net v.3.7.2 FTPClient 从远程服务器获取文件零大小
- flutter - Flutter如何在容器上使用拖放