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

是否值得缓存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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题