Cloudflare机器人缓存问题
我正在使用CloudFlare Worker从GitHub存储库中获取数据并缓存。工人似乎可以缓存文件并将其发送给用户,但以某种怪异的顺序发送。
github repo
<h1>Rocket</h1>
<img src=rocket.png>
<img src=rocket2.png>
强>“ r” 是GitHub的响应; “ req” 是 event.request
let cache = caches.default;
var cacheData = {body: req.body,method: req.method}
添加到缓存中
await cache.put(new Request(req.url,cacheData), await fetch(r.download_url));
以获得高速缓存(从技术上讲是最重要的)
var pCache = await cache.match(new Request(req.url,cacheData))
if(!!pCache)return pCache
对这会导致的任何想法?
I am using a Cloudflare worker to get data from a GitHub repository and cache it. The worker appears to cache the files and send them to the user, but in some weird order.
GitHub Repo
<h1>Rocket</h1>
<img src=rocket.png>
<img src=rocket2.png>
Response
code for caching
"r" is the response from GitHub; "req" is event.request
let cache = caches.default;
var cacheData = {body: req.body,method: req.method}
To add to cache
await cache.put(new Request(req.url,cacheData), await fetch(r.download_url));
To get cache (technically on top)
var pCache = await cache.match(new Request(req.url,cacheData))
if(!!pCache)return pCache
Any ideas for what would cause this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
而不是使用缓存API,您还可以通过通过
cf
将Caching设置传递到fetch(...)
来允许CF处理缓存。Instead of using Cache API you could also allow CF handle caching by passing caching settings via
cf
tofetch(...)
.问题归因于某个文件的多个请求。
我没有使用fetch,而是使用了缓存。
The issue was due to multiple requests to a certain file.
Instead of using fetch, I used the cache.