-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Issue-218: Cache Initial Post API Calls #219
Feature: Issue-218: Cache Initial Post API Calls #219
Conversation
This essentially turns of default automatic revalidations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍣
@@ -1,4 +1,5 @@ | |||
/* eslint-disable camelcase */ | |||
import useSWRImmutable from 'swr/immutable'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@efuller Does disabling automatic revalidation eliminate the need for workarounds like this one? https://l.alley.dev/ca8db44a8f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dlh01 I think it could. useSWRImmutable
will simply just cache an API call and unless that request changes in any way, it will continue to use the cache.
The use case I wanted to guard against was the revalidation after switching tabs. Here are some docs on revalidation and there are a ton of additional options as well.
I think it could be worth a try!
…l-query-api-calls # Conflicts: # package-lock.json
Summary
This PR introduces
SWR
which will help to cache API responses that are identical calls. TheuseSWRImmutable
hook is used so that automatic revalidation is not turned on.Reviewer Notes
Will bump version after CR.
Description
When loading a page in the editor that is powered by the query block, there are several API calls to the API for gathering the posts needed. Many of these API calls are the same. Find a way to increase performance by minimizing the number of API calls upon load.
Testing
Before merging in, it would be great to get another set of 👀 on actual testing in the editor.
Ticket
Fixes #218