Skip to content

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

@westonruter

Description

@westonruter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs DevAnything that requires development (e.g. a pull request)[Plugin] Optimization DetectiveIssues for the Optimization Detective plugin[Type] EnhancementA suggestion for improvement of an existing feature

    Projects

    Status

    Done 😃

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions