h5p / h5p-wordpress-plugin

Adds support for H5P Content in WordPress.
https://wordpress.org/plugins/h5p/
71 stars 74 forks source link

Content Type Hub Cache - Cache refreshes too often on Wordpress multisite #164

Closed n-goncalves closed 11 months ago

n-goncalves commented 1 year ago

Hi,

We are running a Wordpress Multisite with h5p available as one of the plugin, but not as a network activated plugin. Each site of the network can enable it if they so choose.

H5P has a shared table accross the network wp_h5p_libraries_hub_cache that it uses to keep track of h5p libraries. However the option that will be used to check if the cache needs to be refreshed, h5p_content_type_cache_updated_at, is specific to each site which have enabled the H5P extension. Therefore the cache will be updated once a week for each website that has enabled the extension doing a lot of unecessary calls to api.h5p.org.

(In our case, this is an issue for us because refreshing the cache means truncating the wp_h5p_libraries_hub_cache table which causes the table definition to change. And when the table definition changes, a mysqldump can't be completed and ends in a error. The more site that enable H5P, the more probability that one of these cache refreshes happens during the mysqldump process.)

What I propose is that on a multisite install, the h5p_content_type_cache_updated_at option should be stored at the network level. That would be in line with what it intends to do as it's a shared cache and would as a bonus reduce the number of requests done to the h5p.org website to fetch that data.

Would you be interested in a Pull Request that changes that ?

Thanks for reading.

icc commented 1 year ago

I agree, there is no need to update it so often. Please feel free to create a PR for this if you have the time, and I'll have a look.