© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•3y ago•
6 replies
node java

Can Cloudflare cache html response from worker?

Dear members,

I really appreciate your time to look at my problem, I’m new to workers.

I created a worker to return a string as HTML.

Can Cloudflare cache html response from worker? I did not see it cache the HTML response
I have tried to add a response header “Cache-Control”

“

export default {
  async fetch(request, env, ctx) {
    
    const url = new URL(request.url);
    const html = 

export default {
  async fetch(request, env, ctx) {
    
    const url = new URL(request.url);
    const html = 
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1> ${url} ------> ${new Date().toLocaleString()}"</h1>
<p>This markup was generated by a Cloudflare Worker.</p>
</body>
;
 
    return new Response(html, {
      headers: {
        "content-type": "text/html;charset=UTF-8",
        "Cache-Control": "public, max-age=300, s-maxage=600"
      },
    });
  }

};

“
;
 
    return new Response(html, {
      headers: {
        "content-type": "text/html;charset=UTF-8",
        "Cache-Control": "public, max-age=300, s-maxage=600"
      },
    });
  }

};

“

I also tried to create a cache rule for cache everything. I still did not see a catch header available in response.

My worker URLs:
https://whatfood-sow-worker.whatfood.workers.dev/
https://production.whatfood-sow-worker.whatfood.workers.dev/
https://sow.whatfood.work/

How to achieve cache HTML response?
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to cache worker response?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago
Cloudflare worker Cache not work
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago
Bypassing cache from worker fetch
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
10mo ago