-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Implement basic in memory cache for rich link previews data #32741
Conversation
Size Change: +23 B (0%) Total Size: 1.05 MB
ℹ️ View Unchanged
|
packages/editor/src/components/provider/use-block-editor-settings.js
Outdated
Show resolved
Hide resolved
13e7602
to
8d986c9
Compare
I have no idea what happened to this PR... I didn't hit merge intentionally. |
Let's try reopening... |
@kevin940726 @draganescu Now uses
Let me know what you think and if this tests ok for you. |
packages/core-data/src/fetch/__experimental-fetch-remote-url-data.js
Outdated
Show resolved
Hide resolved
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.
LGTM, thanks!
packages/core-data/src/fetch/__experimental-fetch-remote-url-data.js
Outdated
Show resolved
Hide resolved
@kevin940726 I also added some automated test coverage. This was prompted by the additional complexity of adding the cache. |
3251f37
to
8df338e
Compare
This comment has been minimized.
This comment has been minimized.
706ef38
to
71072dd
Compare
71072dd
to
bb3a9f2
Compare
Rebasin...again... |
Description
Currently, each time you preview an external URL an HTTP request is made to the REST API for that data. For some people this could be additional bandwidth that they don't want to expend.
To avoid this, this PR implements a very simple in-memory (only) cache on a per-URL basis.
If the URL has been previewed before for the same request then the same data-set will be returned from the local cache.
As this dataset is cached at a block editor settings level we don't loose the information between mounting/unmounting of the
<LinkControl>
component.I'm not feeling great about burdening the block editor settings with yet more rich preview related code so any suggestions or improvements are most welcome.
Fixes #32554
How has this been tested?
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).