WordPress,缓存高级自定义字段还是其他解决方案? [英] Wordpress, Cache advanced custom fields or maybe other solution?

查看:92
本文介绍了WordPress,缓存高级自定义字段还是其他解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在弄清楚我的WordPress网站中的哪个插件导致页面加载速度降低之后,这碰巧是最重要的插件ACF(高级自定义字段Pro)。

After having a hard time figuring out what plugin in my WordPress site causes a low page load speed, this happens to be the most important plugin ACF (advanced custom fields Pro).

但是我想我知道原因,我自己创建了一个可以满足我需求的主题,但是在此主题中,post循环加载了几个ACF字段(不幸的是,我不得不这样做),这些字段已加载使用基本调用函数 get_field(),但是可能因为此字段在循环内会导致较长的加载时间(极高,这实际上会增加整整4秒钟的加载时间时间!!)。

But I think I know the reason, I created a theme on my own that feet my needs, however in this theme the post loop load few ACF fields (and I just have to do that unfortunately ), the fields are loaded with the basic call function get_field(), but probably because this fields are inside the loop this causes a long load time ( extremely high, this actually add a entire 4 seconds the load time!!).

我是一名开发人员,但我不是专业人士,但据我所知,因为每次函数 get_field ()调用查询,这会使页面加载时间很长,所以我发现也许有一种方法可以在循环之前缓存我需要的所有字段,这样就不会花太多时间加载时间?还是有我无法想到的更好的解决方案?
真的很欢迎任何想法,因为我被困住了,希望有人在这里有了新想法。

I am a developer but I am not professional one but as much as I understand this happens because each time the function get_field() calls a query and that makes the long page load time, so I figured out that maybe there is a way to cache all the fields that I need before the loop so it won't take so much time to load? Or maybe there is much better solution that I can't think about? Seriously any ideas are welcome, because I am stuck and hoping there someone here with a fresh idea.

推荐答案

I '我对ACF插件不熟悉,但是您似乎非常确定这是导致问题的原因。默认情况下,无论您是一千还是一千,自定义字段都不会影响性能。参见这篇文章我在自定义字段的问题上已经做过

I'm not familiar with the ACF plugin, but it seems that you are very sure that this is causing the issue. By default, custom fields should not impact performance, whether you have one or one thousand. See this post I have done on the issue of custom fields

我建议您下载并安装一个插件,例如查询监视器,其中会显示所有屏幕上有关数据库调用数量和每个数据库调用花费的时间的相关信息。请注意,不要在生产站点上运行它。在本地测试安装上执行此操作,或将您的站点置于维护模式。您不希望您的用户被对他们来说毫无意义的查询信息页面所吸引:-)。如我所说,该插件将信息直接打印到屏幕上

I would sugget that download and install a plugin like Query Monitor which prints all the relevant info to screen about the amount of db calls and the time taken for each db call. Just a note, don't run this on a production site. Do this on a local test install or put your site on maintance mode. You don't want your users being dished up with pages of query info that will not make sense to them :-). As I said, the plugin prints the information straight to the screen

这篇关于WordPress,缓存高级自定义字段还是其他解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆