WordPress / performance

Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.
https://wordpress.org/plugins/performance-lab/
GNU General Public License v2.0
362 stars 98 forks source link

Activation of plugin that registers a new tag visitor should automatically make URL Metrics stale #1424

Open westonruter opened 2 months ago

westonruter commented 2 months ago

When activating a plugin that registers a new tag visitor for Optimization Detective, this should automatically result in all existing URL Metrics to be considered stale. This is so that new URL Metrics can be gathered which take into account the new tag visitor(s). Additionally, each tag visitor should perhaps taken an optional version identifier which can also be used to invalidate cached URL Metrics when the version is bumped. When a URL Metric is stored, there should be a new field that contains the "ETag" of sorts. This ETag would consist of a list of all of the tag visitors' IDs and their versions. For example:

image-prioritizer-img:1.0,embed-optimizer:1.1,auto-sizes:0.1

At runtime if the generated string for the current environment does not match this field in the URL Metric, then it would be the same as if the URL Metric's timestamp is old enough that it is considered stale here:

https://github.com/WordPress/performance/blob/08eba80fd8609add2df44d9960dc011868dc5d93/plugins/optimization-detective/class-od-url-metrics-group.php#L230-L235

Related to this is #1419 which proposes that tag visitors be allowed to declare other tag visitors as dependencies. In this way, OD_Tag_Visitor_Registery is increasingly starting to look like WP_Scripts or WP_Script_Modules.

westonruter commented 1 week ago

This is closely related to https://github.com/WordPress/performance/issues/1466 where the registered tag visitors should be considered one of the bits of internal page state that comprise the "ETag" for a URL Metric.