Skip to content

Conversation

@ilicfilip
Copy link
Contributor

@ilicfilip ilicfilip commented Dec 10, 2025

We got a report from the user that the plugin slowed down his site, by investigating I found that we do get_option( 'option_optimizer' ) on every page load in register_hooks method. The reason was to set the accessed_options array.

Fetching options shouldn't be necessary on every page load, especially not that early, so I have replaced initial value of accessed_options with empty array. Then on shutdown hook, after the page was loaded for the user, option_optimizer entry is updated with the collected data.

This should speed up the page loading for the user as is, but there are still some room for improvement:

  1. We can add an option to disable / enable option tracking, that way user can keep the plugin activated but tracking (which can be performance costly) doesnt run all the time.
  2. Also we can add a filter so active tracking can be fine tuned, for example tracking is active only for specific user role.

Both align with Settings page which is added in #59 (comment)

  1. One more thing that we could do is that on every page load we store accessed options in temporary wp_option entry. Then after some time interval (every hour?) we update option_optimizer (which can be much larger) with collected data. The downside is that the stats would be updated with a delay, but if plugin is collecting data 24/7 then it maybe is not that important.

@ilicfilip ilicfilip requested a review from jdevalk December 10, 2025 10:51
@github-actions
Copy link

github-actions bot commented Dec 10, 2025

Test on Playground
Test this pull request on the Playground
or download the zip

@ilicfilip
Copy link
Contributor Author

I have implemented 3. - the update interval is 5 minutes (but it is filterable).

@ilicfilip ilicfilip mentioned this pull request Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants