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

Implement garbage collection for URL metrics posts #895

Closed
westonruter opened this issue Dec 5, 2023 · 2 comments
Closed

Implement garbage collection for URL metrics posts #895

westonruter opened this issue Dec 5, 2023 · 2 comments
Labels
[Plugin] Optimization Detective Issues for the Optimization Detective plugin

Comments

@westonruter
Copy link
Member

westonruter commented Dec 5, 2023

Feature Description

In the Image Loading Optimization module (see #869), detection logic may run when a visitor lands on a page to collect metrics for that URL, namely which element is LCP and which images were in the initial viewport. This information is then sent to a REST API endpoint and is then stored in an ilo_url_metrics post. Over time, URL metrics will be updated in this post as more visitors land on the page. However, a post gets deleted and the URL for which an ilo_url_metrics post was created, then at present the ilo_url_metrics will persist indefinitely. There should be a cron job that does garbage collection of these posts ilo_url_metrics when they are excessively stale. For example, if the post_modified_gmt for a given post is over a month old, then the post could be deleted.

🆕 This should also involve implementing an uninstall.php which deletes all instances of the custom post type at uninstallation.

@thelovekesh
Copy link
Member

For example, if the post_modified_gmt for a given post is over a month old, then the post could be deleted.

I think it would be better to let the user set the TTL for an entry. By default, we can keep it to ~30-45 days?

@westonruter
Copy link
Member Author

I don't think we need to let the user set the TTL. The URL metrics post will be continually refreshed according to how long a URL metric is considered fresh. So a URL metrics post will only be garbage-collected if there are zero visits that keep the URL metrics over the course of a month. We can revisit later if this needs to be further configurable. For now let's just delete any posts that haven't been modified in a month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Optimization Detective Issues for the Optimization Detective plugin
Projects
None yet
Development

No branches or pull requests

2 participants