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.
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(), inOD_URL_Metric_Groupnot accessing\OD_URL_Metric_Group::$url_metricsdirectly, but instead accessing some helper method likeget_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 theOD_URL_Metric_Group::$result_cachewhich is cleared whenever theadd_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.