TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Caching tricks with Cloudflare Workers

6 点作者 dhxt将近 6 年前

1 comment

kentonv将近 6 年前
This example could be simplified somewhat if you&#x27;re willing to leak the generated `ua` query parameter back to the origin server. Most servers will simply ignore unexpected query parameters, so this is likely to work fine.<p>In that case, you could change the fetch() call to:<p><pre><code> response = await fetch(newRequest); </code></pre> And then make sure you set a page rule to &quot;cache everything&quot; on your whole site (otherwise by default HTML won&#x27;t be cached since it&#x27;s often dynamic).<p>Then you can remove the explicit `cache.match()` and `cache.put()` calls from this example, since the `fetch()` call will implicitly perform the caching you want.<p>(I&#x27;m the tech lead of Cloudflare Workers.)
评论 #20161433 未加载