Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Performance of Block Settings on every page load without caching #1005

@mikejolley

Description

@mikejolley

This was reported in woocommerce/woocommerce#24590

Blocks requires certain settings/data to function, and this needs to be present anywhere a block may be used (so admin and frontend, regardless of user type). This is output to JSON inline on every page load.

This can be problematic if doing large queries such as getting terms, and counting post types.

Currently, the JSON is generated in Assets.php here:

https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/master/src/Assets.php#L86-L123

Most of this is harmless, with the exception of:

  1. get_terms - this is querying all categories in the store and generating links for each.
  2. wp_count_posts - less intensive but could still be cached.

We should look at either caching this data, using APIs instead as needed instead of grabbing data that may not be used, or making some of this conditonal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    focus: performanceThe issue/PR is related to performance.type: bugThe issue/PR concerns a confirmed bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions