-
Notifications
You must be signed in to change notification settings - Fork 228
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
Closes #6571: Reduce the processing on not-cached page when checking the LCP/ATF data #6610
Closes #6571: Reduce the processing on not-cached page when checking the LCP/ATF data #6610
Conversation
… above the fold table
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more |
assets/js/lcp-beacon.js
Outdated
if (document.documentElement.nextSibling) { | ||
signature = document.documentElement.nextSibling.data; | ||
} | ||
if ( signature && signature.includes( 'Debug: cached' ) ) { |
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 think we should check for something more reliable maybe like the whole sentence as there are some cases where we do not generate timestamp in the footprint.
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 used the same condition as on WPR Inspector (https://github.com/wp-media/wpr-inspector/blob/bd71796388de3c9cc0cff45488de23ce920df6d1/wpr-inspector/inspector.js#L25)
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.
We need to bear in mind that in some hosts our cache is disabled by default also the signature can be removed in cases like when having the whitelabel constant or so.
I need to understand more how do u detect the cached page in depth.
@wordpressfan for these cases, I guess we won't have the choice to do the DB request we want to avoid which is the one checking if LCP data does exists for the page while it isn't even cached yet. We can't check through the DB as it would add another DB Request, which is the opposite of what we want, and there are no other way to determine if a page is cached or not. Except if there is something else I'm missing. The way the current detection work is through the signature, where if the page is cached, we get the following text: |
@jeawhanlee & @wordpressfan Are you okay with the latest changes ? |
For me I have issues with how reliable it can be detecting a cached page with our footprint signature, what if we tried checking the directory if the cache file exists and pass the result (boolean) to the script. |
@Miraeld Looking at wp-rocket's code, there are versions of the code that don't have the timestamp in the signature I think. Typically in case of 3rd party hosting, white label and if time is empty.
Then, of course, it is not perfect because sometimes, comments are removed from cached files. But better done than perfect. WDYT of matching on those two rather than Debug + timestamp? In any cases, better done than perfect: Can we just change the matching to those 2 strings, move forward with this PR and eventually open a follow-up GH issue if there are edge cases you still foresee? |
So based on our conversation yesterday, I guess we have to merge this PR and prepare another issue to enhance it, |
@wordpressfan @jeawhanlee Since @Miraeld will be off end of this week, can you make sure to close this? Thanks 🙏 |
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.
Approved with very minor enhancement
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more |
Expected behavior and observation from QA team discussed here: https://wp-media.slack.com/archives/CUT7FLHF1/p1716202320587489 |
The issue mentioned here #6610 (comment) is fixed, but on PR, nothing is added to the database with warmup (neither after a fresh install, nor after clear critical images) steps: Note: related test plan https://wpmediaqa.testrail.io/index.php?/runs/view/856&group_by=cases:section_id&group_order=asc |
All jobs from that site in SaaS are returning timeout error, I'm checking with Mostafa now what is going on there. |
This was because in SaaS we load the not cached page which doesn't include the signature and this means that the following line returns js error in the console: wp-rocket/assets/js/lcp-beacon.js Line 51 in a6b7622
because |
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.
Working as expected
testrail-report-605.pdf
Description
Fixes #6571
Documentation
User documentation
It won't try to check if LCP data are already existing for non-cached URLs.
Technical documentation
We check if the page is a cached version, if it isn't we will bailout before sending an AJAX call to check if LCP datas are already existing for the URL.
Type of change
New dependencies
N/a
Risks
N/a
Checklists
Feature validation
Documentation
Code style