Skip to content

Boost: Invalidate LCP when Cornerstone Page list is updated #43222

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

Merged
merged 17 commits into from
May 7, 2025

Conversation

LiamSarsfield
Copy link
Contributor

@LiamSarsfield LiamSarsfield commented Apr 24, 2025

Note

Merge this PR after #43151 is merged.

Resolves HOG-82:Invalidate LCP when Cornerstone Page list is updated

Proposed changes:

  • When the Cornerstone pages list is updated, the LCP Optimizer will now re-analyze the LCP for the updated Cornerstone Pages

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

pc9hqz-3tr-p2

Does this pull request change what data or activity we track or use?

N/A

Testing instructions:

Prerequisites:

  • Jetpack Boost plugin installed and activated.

  • Boost Premium is set up.

  • LCP Optimization feature enabled.

    Click here for SQL to check LCP State Option and Storage Posts
    -- Check LCP State (in options table)
    SELECT option_name, option_value
    FROM wp_options -- Replace wp_ with your table prefix if different
    WHERE option_name = 'jetpack_boost_ds_lcp_state';
    
    -- Check LCP Storage (in posts table)
    SELECT ID, post_name, post_content, post_status, post_date_gmt, post_modified_gmt
    FROM wp_posts -- Replace wp_ with your table prefix if different
    WHERE post_type = 'jb_store_lcp';

Testing Cornerstone Page List Update:

  1. Note the current LCP state option value and any existing LCP storage posts. Pay attention to the data, and note the post_modified_gmt timestamps of the existing posts.

    Click here for SQL to check initial LCP State and Storage
    -- Check LCP State (in options table)
    SELECT option_name, option_value
    FROM wp_options -- Replace wp_ with your table prefix if different
    WHERE option_name = 'jetpack_boost_ds_lcp_state';
    
    -- Check LCP Storage (in posts table)
    SELECT ID, post_name, post_content, post_status, post_date_gmt, post_modified_gmt
    FROM wp_posts -- Replace wp_ with your table prefix if different
    WHERE post_type = 'jb_store_lcp';
  2. Go to Jetpack -> Boost.

  3. Add, or remove a Cornerstone Page from the list. Note the approximate time of editing.

  4. Wait a few seconds for the analysis to complete (it should be quick).

  5. Re-check the jetpack_boost_ds_lcp_state option in the wp_options table. Verify its value has been updated (it won't have a timestamp, but the content should reflect recent analysis).

  6. Re-check the wp_posts table for jb_store_lcp posts. Verify that new posts now exist, and their post_date_gmt or post_modified_gmt timestamps are after the time you activated the theme.

    Click here for SQL to check updated LCP State and new Storage posts
    -- Check LCP State (in options table)
    SELECT option_name, option_value
    FROM wp_options -- Replace wp_ with your table prefix if different
    WHERE option_name = 'jetpack_boost_ds_lcp_state';
    -- Expect option_value to contain data reflecting the new analysis state
    
    -- Check LCP Storage (in posts table)
    SELECT ID, post_name, post_content, post_status, post_date_gmt, post_modified_gmt
    FROM wp_posts -- Replace wp_ with your table prefix if different
    WHERE post_type = 'jb_store_lcp' AND post_status != 'trash';
    -- Expect new posts corresponding to visited pages with recent timestamps
  7. Verify that there is a record for the LCP Storage results for each valid Cornerstone from the list.

@github-actions github-actions bot added [Boost Feature] Lcp [Plugin] Boost A feature to speed up the site and improve performance. [Status] In Progress labels Apr 24, 2025
Copy link
Contributor

github-actions bot commented Apr 24, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Boost plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Apr 24, 2025
- Consolidated LCP data reset and analysis into the reset_and_analyze method.
@LiamSarsfield LiamSarsfield added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. labels Apr 24, 2025
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Apr 24, 2025
@LiamSarsfield LiamSarsfield requested a review from a team April 24, 2025 09:59
@LiamSarsfield LiamSarsfield marked this pull request as ready for review April 24, 2025 09:59
Copy link

jp-launch-control bot commented Apr 24, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/boost/app/assets/src/js/features/cornerstone-pages/meta/meta.tsx 0/67 (0.00%) 0.00% 2 ❤️‍🩹

Full summary · PHP report · JS report

Coverage check overridden by Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR .

@LiamSarsfield LiamSarsfield added [Status] Needs Review This PR is ready for review. Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Apr 24, 2025
@LiamSarsfield LiamSarsfield changed the title Add/boost/lcp/invalidate-cornerstone-list Boost: Invalidate LCP when Cornerstone Page list is updated Apr 24, 2025
Copy link
Member

@dilirity dilirity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While testing this, I noticed that it sends requests to the cloud and analyses the LCP, but the UI is never updated.

Then I checked how Cloud CSS is handled and found this PR - https://github.com/Automattic/jetpack/pull/40009/files

I think it makes more sense to handle the re-analyze via the UI so we give the user feedback right away. Otherwise, they'd have to refresh the page to see that LCP was optimized again.

Nitpick: However, looking at the way Cloud CSS is handled, although simple, I wonder if it make sense to do it via the UI. That means that we're unable to do this via PHP. Ideally, we'd update the cornerstone pages list and dispatch a new LCP analysis via the back-end. Then at the same time, update the UI to a polling state. Though this seems clunky and I think we should stick with updating via the UI. If we decided that it's necessary to start the analysis via the back-end, we can always update it.

EDIT:
@LiamSarsfield I've updated the LCP analysis request to happen via the UI in 4a4aca0.

Take a look and tell me what you think.

@LiamSarsfield
Copy link
Contributor Author

Good catch @dilirity, I took the majority of inspiration from Cache Preloading, but that didn't need a UI aspect to it, hence it wasn't needed.

Though this seems clunky and I think we should stick with updating via the UI. If we decided that it's necessary to start the analysis via the back-end, we can always update it.

I think this is okay for now as this is the only place where Cornerstone Pages are being updated, but we should be aware of UI side effects such as this if we ever do allow Cornerstone Pages to be updated elsewhere (unlikely though).

@LiamSarsfield LiamSarsfield requested a review from dilirity May 6, 2025 15:02
Base automatically changed from add/boost/lcp/invalidate-conditions to trunk May 7, 2025 07:21
Copy link
Member

@dilirity dilirity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@dilirity dilirity merged commit 508956a into trunk May 7, 2025
69 of 70 checks passed
@dilirity dilirity deleted the add/boost/lcp/invalidate-cornerstone-list branch May 7, 2025 08:07
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Boost Feature] Cloud CSS [Boost Feature] Lcp Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Plugin] Boost A feature to speed up the site and improve performance. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants