【问题标题】:Does the size of Timber global $context has impact on performanceTimber global $context 的大小对性能有影响吗
【发布时间】:2021-12-19 12:13:33
【问题描述】:

尝试优化网站,想知道这是否有一些影响。

我正在向$context 添加一些变量...

  public function add_to_context( $context ) {
    $context['query'] = $GLOBALS['wp_query']->query_vars;
    $context['menu'] = new Timber\Menu('main-menu', array( 'depth' => 2 ));
    ...
    $context['footer_menu'] = new \Timber\Menu( 'footer-main-menu' );
    $context['footer_support'] = new \Timber\Menu( 'footer-support-menu' );
    $context['footer_legal'] = new \Timber\Menu( 'footer-legal-menu' );```

【问题讨论】:

  • Timber 带有一个timer helper,您可以使用它来查看它对性能的影响有多大。

标签: performance optimization timber


【解决方案1】:

我强烈建议你使用transient API

另外,还有一些关于 Timber 缓存的文档。 https://timber.github.io/docs/guides/performance/

另外,请检查这部分。 https://timber.github.io/docs/guides/performance/#measuring-performance这就是你想知道的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-12
    • 2014-01-05
    • 1970-01-01
    • 1970-01-01
    • 2011-02-01
    相关资源
    最近更新 更多