javascript - 使用 fetch API 忽略条件 GET
问题描述
我正在使用 Discord.js/Node.js获取和解析 RSS 提要 ( https://www.mangaupdates.com/rss.php )。我目前正在尝试添加条件If-Modified-Since
标头以向 RSS 提要发出条件 GET 请求。这是我的代码:
fetch(mangaUpdatesRSS, {
method: 'GET',
headers: {'If-Modified-Since': new Date().toUTCString()}
})
.then(res => {
console.log(res.status);
响应状态始终200
是即使它应该仅在自fetch
调用命令时被修改时才发出请求。
解决方案
即使请求的资源是最新的,Fetch API 也会在内部替换304
。200
你对此无能为力。
推荐阅读
- java - 蓝牙数据传输
- google-cloud-platform - 带有授权 API 密钥的 Google URL Shorter API 返回 403
- ios - WKWebView 从 Bundle 和 Document 目录加载文件
- grafana - 如何关闭表grafana中的自动生成列
- selenium - 如何在一个浏览器中运行相同功能文件的所有场景?使用硒,Java,黄瓜
- java - 带有 TLS 的 REST 客户端返回 SSLHandshakeException:收到致命警报:handshake_failure
- sql - SQL Server 2014 - 模拟和 CTE 循环
- r - 多个axis.text.x名称着色不适用于ggplotly()
- azure - 移动到另一个资源组后更改应用服务计划不起作用
- google-apps-script - 服务错误:Spreadsheets(line... with .setColumnFilterCriteria