-
Notifications
You must be signed in to change notification settings - Fork 800
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
Write Brief: Load unconfident words from backend and update caching #39975
Write Brief: Load unconfident words from backend and update caching #39975
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
// The If-Modified-Since header causes a CORS preflight request error, so we need to check manually | ||
if ( lastRequested ) { | ||
const headData = await fetch( url, { method: 'HEAD' } ); | ||
const lastModified = headData.headers.get( 'last-modified' ); |
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.
The etag
should be more precise, but it is always null
for some reason, even though I can see it in the browser tools 🤔
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.
That's because CORS requests have limited headers that are accessible. If we can set access-control-expose-headers
server side (not sure how feasible this is) then we can add etag there and will have access to it.
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.
I could not get the debug messages to show up consistently, but everything else behaved as described. I added an extra word to the unconfident words, reloaded, and it appeared. Subsequent refreshes I only saw the HEAD request. If I modified the dictionary again and reloaded then I saw the HEAD + GET requests. Nice work! 👍
did you enable “all” messages on devtool console. For some reason debug package logs outside of error/warning/info scope, so you need to select “all” messages |
Yeah I have noticed that, and also Chrome sometimes defaults to not showing "All" even though I have clicked it numerous times. I did initially see some debug messages (not the ones Douglas described) but they didn't come up after the initial load. Everything worked exactly as described, so it's entirely possible I did not have "All" clicked and just didn't notice 😅 |
Fixes ##39899
Proposed changes:
last-modified
header value for cache invalidation, making a HEAD request once when opening the editorOther information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
debug
enabled withlocalStorage.setItem( 'debug', '*' );
.Fetching feature data for type: <feature>. language: en
Loaded data from server <feature> en
requestTime
anddata
.jetpack-ai-breve-spelling-context-en
) is removeden.json
, one for each feature.Fetching feature data for type: <feature>. language: en
Data not modified <feature> en
Loaded data from local storage <feature> en
s0.wp.com
,s1.wp.com
ands2.wp.com