cachingcloudflarehttp-caching

Does Cloudflare support stale-while-revalidate?


Cloudflare documents a list of directives for the Cache-Control header, including stale-while-revalidate.

  • stale-while-revalidate=<seconds>
    When present in an HTTP response, the stale-while-revalidate Cache-Control extension indicates that caches MAY serve the response in which it appears after it becomes stale, up to the indicated number of seconds since the object was originally retrieved.

I set my Cache-Control header to public, max-age=0, stale-while-revalidate=30 but I never seem to get a cache hit. Does Cloudflare actually support this?


Solution

  • No, Cloudflare doesn't support stale-while-revalidate.

    The last word from them was in a blog post from April 2024.

    https://blog.cloudflare.com/browser-rendering-api-ga-rolling-out-cloudflare-snippets-swr-and-bringing-workers-for-platforms-to-our-paygo-plans/

    Coming soon: asynchronous revalidation with stale-while-revalidate

    One of the features most requested by our customers is the asynchronous revalidation with stale-while-revalidate (SWR) cache directive, and we will be bringing this to you in the second half of 2024.

    There's a forum thread about it here: https://community.cloudflare.com/t/support-for-stale-while-revalidate/496788