FortAwesome / wordpress-fontawesome

Font Awesome Official WordPress Plugin
Other
56 stars 19 forks source link

Refine release metadata storage #103

Closed mlwilkerson closed 3 years ago

mlwilkerson commented 3 years ago

The goal of this PR is to change when we issue queries to the API server for releases metadata, and how we store it.

The big idea is that we want to (almost) never issue a synchronous network request from the WordPress server to the Font Awesome API server to load releases metadata on normal front end page loads. In fact, we only ever want to issue that request when:

  1. an admin user loads the settings page (and even then, we only do it when it's been a while)
  2. upgrading, and only when necessary

So we'll store the releases metadata in a normal option, instead of a transient. Thus it will not expire, and should never be automatically "cleaned up" as transients may sometimes.

We also don't want to load all of that releases metadata into the PHP process memory unless we need it, and we very rarely need it. We definitely don't want to autoload all of that data, especially because we never need it when Using a Kit. And when we're Using a CDN, we really only need to load it when the admin user needs to know the options for changing the version selection. But on the vast majority of loads, we only need releases metadata for the current configured version, which is almost always the last used.

So we'll store just the metadata for that last used release in a transient. Therefore, on most page loads when Using CDN, we won't load the whole releases metadata at all--just the metadata for last used release.