[WordPress] Instant Articles for WP 與 Yoast SEO 外掛的效能問題

本篇文章更新時間:2019/02/16
如有資訊過時或語誤之處,歡迎使用 Contact 功能通知。
一介資男的 LINE 社群開站囉!歡迎入群聊聊~
如果本站內容對你有幫助,歡迎使用 BFX Pay 加密貨幣新台幣 贊助支持。


自從換主機後,有一段時間沒有來調教網站,有快取的情況下速度自然是還可以,但發現登入後的原始速度有點糟糕,尤其是導向吐出內容方法的頁面( the_content()

測試那頁面的速度居然可以跑到 12 秒!太不可思議的慢,然後裝了 Query Monitor 來看看,發現第一次瀏覽文章頁的時候 Instant Articles for WP 都會去對引用的其他 WordPress 連結請求 post meta

WP_Http->request()
 wp-includes/class-http.php:227
WP_Http->get()
 wp-includes/class-http.php:594
wp_safe_remote_get()
 wp-includes/http.php:70
WP_oEmbed->discover()
 wp-includes/class-oembed.php:388
WP_oEmbed->get_provider()
 wp-includes/class-oembed.php:247
instant_articles_embed_oembed_html()
 wp-content/plugins/fb-instant-articles/embeds.php:33
apply_filters('embed_oembed_html')
 wp-includes/plugin.php:235
WP_Embed->shortcode()
 wp-includes/class-wp-embed.php:239
WP_Embed->autoembed_callback()
 wp-includes/class-wp-embed.php:357
preg_replace_callback()
 wp-includes/class-wp-embed.php:357
WP_Embed->autoembed()
 wp-includes/class-wp-embed.php:339
apply_filters('the_content')
 wp-includes/plugin.php:235
wp_trim_excerpt()
 wp-includes/formatting.php:3274
apply_filters('get_the_excerpt')

Debug 資訊可以從最底看到最上

然後又因為頁面文章中,我有引用兩篇別人的文章,導致網站對外求的時間加乘在網站裡。

再來就是 Yoast SEO 也會因為內容載入的流程再次觸發 embed_oembed_html 事件,導致重複請求。

試算:一個對外網站請求用 2 秒來算,重複請求兩個網站約多出 8 秒的載入,很可觀阿!!

解法可以是廢掉 Instant Articles 中的嵌入頁面功能,改為其他訊息 或是 自己先補上 transient 的做法,在第二次請求的時候先讀取快取來加速~

remove_filter( 'embed_oembed_html', 'instant_articles_embed_oembed_html');//移除的做法

這問題會隨著當前頁面引用的內容多寡,與引用的資源存取速度進而決定你網站效能,要怎麼做就看人囉!

是說這樣看下來 WordPress 網站變慢好像跟 Yoast SEO 沒關係,但我想這種組合應該是不少人也一樣(IA for WP 這款外掛是 Automattic 出品,懂得人選擇上應該會用這為主),不過速度取決於網站內文章的組合,就要特別注意了。


Share:

作者: Chun

資訊愛好人士。主張「人人都該為了偷懶而進步」。期許自己成為斜槓到變進度條 100% 的年輕人。[///////////____36%_________]

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *


文章
Filter
Apply Filters
Mastodon