statamic / seo-pro

An all-in-one site reporting, metadata wrangling, Open Graph managing, Twitter card making, sitemap generating, turn-key addon for Statamic.
https://statamic.com/addons/statamic/seo-pro
52 stars 33 forks source link

Reports section performance improvements #307

Closed jesseleite closed 6 months ago

jesseleite commented 7 months ago

This PR improves page load performance in the reports section by quite a lot.

We're now caching report status, score, and pages crawled stats to the report's yaml file, so that the index view doesn't need to load all of the report's pages to calculate this stuff in realtime for each report.

If I try to load the reports index w/ 10 reports w/ 2500 entries each on SEO Pro 5.3.0 (current tagged version), it takes 19 seconds to load...

CleanShot 2023-12-12 at 16 04 15

Whereas now it's down to ~400ms with the same data...

CleanShot 2023-12-12 at 16 07 43

If legacy reports exist from past SEO Pro versions, they will be gracefully updated and cached the first time the user hits the reports index, and this is done via ajax to keep the page load feeling snappy even in these situations.

For example, the bottom 5 reports here are legacy reports (without the above mentioned cache)...

CleanShot 2023-12-12 at 15 44 30

Once these legacy reports are all loaded and updated, the loading spinners are unnecessary because the score is read from the cached stats in the yaml.

And finally, though this PR specifically doesn't do much to increase the speed on the report show page, it caches all the stats needed to display the header cards, so the spinner is only necessary for the individual pages below...

CleanShot 2023-12-12 at 15 53 11