Posted On: May 17, 2023

Amazon CloudFront announces support for stale-while-revalidate and stale-if-error cache control directives, which can improve performance and availability. The stale-while-revalidate directive instructs CloudFront to immediately deliver stale responses to users while it revalidates caches in the background. The stale-if-error directive defines how long CloudFront should reuse stale responses if there’s an error, which provides a better user experience.

With stale-while-revalidate, CloudFront can deliver faster responses from its 480+ edge locations and maximize cache hit ratios for better performance after cache expiration. With the stale-while-revalidate directive, your users no longer need to wait for responses from origins, because stale content is rapidly served from caches. stale-while-revalidate is ideal for content that refreshes frequently or unpredictably, or where content requires significant time to regenerate, and where having the latest version of the content is not essential. The stale-if-error directive enhances the user experience and improves availability by serving stale content when origins return an error. 

Support for these directives is now available in all CloudFront edge locations, at no additional cost. You define the directives from your origin server, and CloudFront honors the behaviors based on your directives. For more information, see  the Amazon CloudFront Developer Guide.