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 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用