Adding "public" directive to Cache-Control header


Current Cache-Control header produced by Cloudflare is:

max-age=3600, must-revalidate

How can I add the public directive?


This header is directly the header received from the server. Since the header is already being set, you’ll need to change your application’s configuration or code to add the public directive.

If you want to use workers, this would work:

async function handleRequest(request) {
  const response = await fetch(request)
  let newResponse = new Response(response.body, response)
  newResponse.headers.set('cache-control', 'public, ' + newResponse.headers.get('cache-control'))
  return newResponse
1 Like