
內容簡介
Gambit Cache Menus 可以快取您在前端使用的選單。儘管每個選單只能少了約 18 毫秒的載入時間,但如果您的網站有著大型多層級選單以及大量瀏覽者,那麼速度優化可為您帶來許多好處。
安裝並啟用此外掛後,即可直接運作,不需要進行任何設定。
一般情況下,選單需要載入大約 0.02 秒,啟用此外掛可以將處理時間減少至 0.002 秒。
功能與特色
為每個選單節省約 18 毫秒
使用快取 API(Transient API)
輕量、乾淨的程式碼
如何運作
快取 API 扮演了主要的角色。當前端需要載入選單的時候,已經載入的選單就會被存成一個快取(transient)。下次需要載入選單時,程式會直接使用該快取,以加速載入。當您更新選單或變更選單位置時,程式會強制使其快取過期,以便載入更新的選單。
本外掛同時也是教學
Transients 真棒。如果您對此不熟悉,我們已充分解釋程式碼,您可以從中了解更多。同時,我們也會盡快推出與 Transients 相關的教學文章。
外掛標籤
開發者團隊
原文外掛簡介
Gambit Cache Menus caches the menus that you use in your front end. This may not be much (an estimate of 18 milliseconds per menu), but if you have large multilevel menus, and a lot of site visitors, then the speed savings may bring a lot of benefits.
Just install and activate the plugin, there are no settings page.
A menu rendered normally takes around 0.02 seconds; activating this plugin reduces this step to 0.002 seconds.
Features
Shaves off 18ms per menu
Uses the Transient API
Lightweight
Cleanly coded plugin
How Does it Work
It’s all about the Transient API. When a menu is rendered in the front end, the rendered menu is saved as a transient for caching. Future menu renderings use this cached copy afterwards. When the menu is updated, or when menu locations are changed, the transient is forcibly expired to make way for the updated menu.
This Is Also a Tutorial
Transients are cool. If you’re not familiar with them then we documented the code well so that you can check it out.
There should be a companion tutorial about Transients soon.
