WordPress / WordPress/performance
URL Metrics with mismatched ETags should be disregarded if there are ones with current ETags
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 461
- Forks
- 165
- Avg merge
- 11h 12m
- Merged PRs (30d)
- 28
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with OD_URL_Metric_Group and inspect is_complete(), get_lcp_element(), get_xpath_elements_map(), add_url_metric(), and the result cache. Trace how URL Metrics are selected and how the collection’s current ETag is obtained; done means groups prefer metrics with the current ETag, fall back appropriately when none match, and return results in the intended timestamp order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100