Skip to content
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

URL Metrics with mismatched ETags should be disregarded if there are ones with current ETags #1902

Open
westonruter opened this issue Mar 4, 2025 · 0 comments
Labels
[Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@westonruter
Copy link
Member

Feature Description

This is related to #1896.

A URL Metric can go stale either because it is older than the "freshness TTL" or because its ETag does not match the current ETag for the page. Recall that an ETag is computed with data including the current theme, the active plugins, the modified date of the post, and so on. When someone switches the theme, then all of the current URL Metrics will go stale because the current ETag will change, and what's more is that it is extremely unlikely that any of the collected URL Metrics will be relevant anymore since all of the element XPaths will change. Therefore, I suggest that within a URL Metric Group, if any of the URL Metrics have an ETag that matches the current ETag, that only these URL Metrics should be considered.

As for how to implement this, I think it would involve the methods like is_complete(), get_lcp_element(), get_xpath_elements_map(), in OD_URL_Metric_Group not accessing \OD_URL_Metric_Group::$url_metrics directly, but instead accessing some helper method like get_current_url_metrics() which would first gather the URL Metrics that have a ETag that matches $group->get_collection()->get_current_etag(), and then if that list is empty, to then merge the rest of the URL Metrics. Finally, the result should be sorted by timestamp in descending order (probably). The result can be added to the OD_URL_Metric_Group::$result_cache which is cleared whenever the add_url_metric() method is called.

Maybe there are other implications of doing this that I haven't thought of or maybe there is a better way to do this.

@westonruter westonruter added [Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature labels Mar 4, 2025
@github-project-automation github-project-automation bot moved this to Not Started/Backlog 📆 in WP Performance 2025 Mar 4, 2025
@westonruter westonruter moved this from Not Started/Backlog 📆 to Definition ✏️ in WP Performance 2025 Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature
Projects
Status: Definition ✏️
Development

No branches or pull requests

1 participant