Master
Published: Oct 28, 2020
Last Updated: Apr 13, 2021
Apr 2021
Trial?

When used in appropriate circumstances, our teams have found that the React Hooks library SWR can result in cleaner code and much improved performance. SWR implements the stale-while-revalidate HTTP caching strategy, first returning data from cache (stale), then sending the fetch request (revalidate) and finally refreshing the values with the up-to-date response. We caution teams to only use the SWR caching strategy when an application is supposed to return stale data. Note that HTTP requires that caches respond to a request with the most up-to-date response; only in carefully considered circumstances is a stale response allowed to be returned.

Oct 2020
Assess?

SWR is a React Hooks library for fetching remote data. It implements the stale-while-revalidate HTTP caching strategy. SWR first returns data from cache (stale), then sends the fetch request (revalidate) and finally refreshes the values with the up-to-date response. Components receive a stream of data, first stale and then fresh, constantly and automatically. Our developers have had a good experience using SWR, dramatically improving the user experience with always having data on the screen. However, we caution teams to only use SWR caching strategy when appropriate for an application to return stale data. Note that HTTP requires that caches respond to a request with the most up-to-date response held that is appropriate to the request, and only in carefully considered circumstances is a stale response allowed to be returned.