iworks / sierotki

This is a WordPress plugin which fixes orphans position and replaces space after orphan with hard space, to avoid line-breaking incorrect position.
http://iworks.pl/tag/sierotka/
3 stars 1 forks source link

feat(cache): cache options array #4

Closed simivar closed 1 year ago

simivar commented 1 year ago

the orphang_indicator_options function is called multiple times for both Admin Panel and normal page frontend. This causes the plugins to generate an array of options many times. As this array consists of post types, taxonomies and installed plugins it takes around 140ms of a load time of the webpage. With this cache this value is reduced to 1ms.

This is the load time reported by Code Profiler Pro before changes: image

This is the load time reported after the changes: image

Probably what would be good here is to refresh the cache after new plugin is installed, new taxonomy or post type is created. Or we could add a button to flush it on the options page itself.

iworks commented 1 year ago

@simivar awesome! thank you