使用获取API忽略条件GET [英] Conditional GET ignored with fetch API
问题描述
我正在获取和解析RSS feed( https://www.mangaupdates.com/rss.php )与Discord.js/Node.js.我目前正在尝试添加条件 If-Modified-Since
标头,以向RSS feed发出条件GET请求.这是我的代码:
I am fetching and parsing an RSS feed (https://www.mangaupdates.com/rss.php) with Discord.js/Node.js. I'm currently trying to add a conditional If-Modified-Since
header to make a conditional GET request to the RSS feed. Here is my code:
fetch(mangaUpdatesRSS, {
method: 'GET',
headers: {'If-Modified-Since': new Date().toUTCString()}
})
.then(res => {
console.log(res.status);
响应状态始终为 200
,即使自调用 fetch
命令的时间以来对其进行了修改,也仅应发出请求.
The response status is always 200
even though it should only be making a request if it's been modified since the time of the fetch
command is called.
推荐答案
即使请求的资源是最新的,Fetch API也会在内部用 200
替换 304
.您无能为力.
Fetch API replaces 304
with 200
internally even if the requested resource is up to date. There's nothing you can do about it.
这篇关于使用获取API忽略条件GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!