doutang3815
2018-09-11 08:49
浏览 40
已采纳

是否值得缓存WordPress特定的查询?

I have multiple wordpress specific queries firing when a user visits my homepage. I could have 150+ users visit concurrently with maybe 25+ of them hitting the homepage.

Here is an example of one query:

 $args = array(
'posts_per_page' => 3,
'post_status' => 'publish',
'category' => 37,
'meta_key' => 'total_views',
'orderby' => 'meta_value_num', 
'order' => 'DESC',
    'date_query' => array(
        array(
            'after' => '1 month ago'
        )
    )


);

I have roughly 6 of those queries (and similar ones) on the Homepage.

I've recently been implementing phpfastcache across most areas of the site and for the most part it has worked really well (especially with lowering entry process limits).

I did hear that wordpress queries are generally well optimized and there is usually no point in caching them.

Does this still hold true in my case?

EDIT:

Caching times:

1 queries is cached for 10 minutes.

2 queries are cached for 60 seconds each (they are part of a "here is a recently updated section"). I could in theory increase this slightly.

The rest are cached for half a day (which could be increase to a day or two potentially).

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doulingzou1712 2018-09-11 23:30
    已采纳

    To be honest it's a case by case study. The cache can degrade performances when your disk is not an SSD or flash-based disk (assuming you make use of "Files" driver).

    But most of time with a memory-based driver (SSDB, Redis, Memcache, etc), you will notice a performance gain, especially for SQL queries that does not use indexes (or partially make use of them).

    I've been worked on multiple php CMS like Drupal, Wordpress, Prestashop etc, and to be honest a well-configured cache is a non-negligible boost to your website especially when using a separated cache backed kv-based.

    To finish on a simple line, when not sure, I'm first making an approximation benchmark test on a list of content with and without caching (usually with browser debugger). If the performance gain is barely noticeable, I'm usually continuing with a microtime test of the whole page.

    Disclaimer: I'm the Phpfastcache's owner.

    打赏 评论

相关推荐 更多相似问题