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

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

Open
westonruter opened this issue Jul 31, 2024 · 0 comments
Labels
Needs Dev Anything that requires development (e.g. a pull request) [Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@westonruter
Copy link
Member

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:

$current_time = microtime( true );
foreach ( $this->url_metrics as $url_metric ) {
if ( $current_time > $url_metric->get_timestamp() + $this->freshness_ttl ) {
return false;
}
}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Dev Anything that requires development (e.g. a pull request) [Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature
Projects
Status: Not Started/Backlog 📆
Development

No branches or pull requests

1 participant