You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/optimization-detective/docs/hooks.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -367,3 +367,19 @@ The ETag is a unique identifier that changes whenever the underlying data used t
367
367
6. The list of active plugins.
368
368
369
369
A change in ETag means that any previously-collected URL Metrics will be immediately considered stale. When the ETag for URL Metrics in a complete viewport group no longer matches the current environment's ETag, new URL Metrics will then begin to be collected until there are no more stored URL Metrics with the old ETag.
370
+
371
+
### Filter: `od_url_metric_garbage_collection_ttl` (default: 3 months in seconds)
372
+
373
+
Filters the expiration age (TTL) after which an `od_url_metrics` post will be garbage collected if it has not been modified since that time.
374
+
375
+
```php
376
+
add_filter( 'od_url_metric_garbage_collection_ttl', function (): int {
377
+
return 6 * MONTH_IN_SECONDS;
378
+
} );
379
+
```
380
+
381
+
To prevent garbage collection of `od_url_metrics` posts, add a filter that returns zero:
Then in your template code you may continue to use `isset( $_GET['thank_you'] )` but you might as well use `get_query_var( 'thank_you' )` instead.
188
188
189
-
When an `od_url_metrics` post has not been updated in a month then it is garbage-collected, since it is likely the original URL has gone away.
189
+
When an `od_url_metrics` post has not been modified for three (3) months, it will then be garbagecollected since it is likely the original URL for the metrics has gone away. If you have a site that gets very little traffic and you want to increase the TTL to prevent premature garbage collection, you can use the [`od_url_metric_garbage_collection_ttl`](https://github.com/WordPress/performance/blob/trunk/plugins/optimization-detective/docs/hooks.md#:~:text=Filter%3A%20od_url_metric_garbage_collection_ttl) filter to increase this.
190
190
191
191
Extensions to Optimization Detective rarely need to directly interface with the custom post type, so far. See the experimental [Optimization Detective Content Visibility](https://github.com/westonruter/od-content-visibility/) plugin which interfaces with the `od_url_metrics` post at submission time to add post meta via the `od_url_metric_stored` action, and then retrieves post meta in the tag visitor via the context object’s `url_metrics_id` property.
0 commit comments