wp-rocket
wp-rocket copied to clipboard
3.16 - Beacon script implementation
Context
As a user, I want WP Rocket to analyse and store LCP/ATF information of my pages so that those images can then be optimised. This issue has the goal to develop the green part of this diagram:
Must be done after #6430 so that it can be tested
Scope a solution
- To implement this, we need to create the beacon script in javascript that will run on pages to collect images.
- A prototype of the script can be found here.
- The script can be created and placed here.
The script needs to collect images of the page, and save them within the database through an AJAX call.
If the script encounter an error, we should save it to the DB as well.
- Add a new Subdir
AJAX
with a controller and a subscriber - The subscriber will have an event
wp_ajax_rocket_lcp
, with a callbackadd_lcp_data()
- The method will call the same named method in the controller
- This method will update the DB based on the result of the script (failed, error, no image, success), while performing security checks
- The controller will need to have a dependency with the DB query class to write in the table
- Add tests
Acceptance Criteria
- Data is added to the DB once the AJAX call is made
Effort estimation:
Effort [M]
Some work is needed here on AC, to check with @Mai-Saad's suggestion:
can be: save optimized images (all types mentioned above) to the database, if any error occurs i.e timeout, …etc, save the error in the database and start retries up to 3 then fail if the error is still there
This issue includes security checks like SQL injection and payload size to avoid to big DB footprint.
smoke test is good here (security, different markups and error cases will be on different GH) testrail-report-592.pdf