基于Redis Object Cache和WP Super Cache的建站文章
導(dǎo)讀:建站文章1.本教程基于寶塔面板(aapanel),如果你不知道什么是寶塔面板(aapanel),請立即關(guān)閉本教程;如果你是手搓黨,請自行研究安裝方法。2.本教程默認你已高端網(wǎng)站建設(shè)網(wǎng)站推廣優(yōu)化seo。
1.本教程基于寶塔面板(aapanel),如果你不知道什么是寶塔面板(aapanel),請立即關(guān)閉本教程;如果你是手搓黨,請自行研究安裝方法。 2.本教程默認你已經(jīng)安裝好了寶塔面板、LNMP環(huán)境以及wordpress程序(不適用于apache)。 3.本教程原理:使用WP Super Cache將php動態(tài)頁面生成靜態(tài)html文件以降低服務(wù)器負載,加快頁面打開速度;使用redis緩存數(shù)據(jù)庫常用數(shù)據(jù),減少數(shù)據(jù)庫查詢。
1.安裝redis
過程不再贅述。
2.安裝php的redis和opcache擴展
3.安裝wordpress的Redis Object Cache和WP Super Cache緩存插件
4.設(shè)置緩存插件
(1)WP Super Cache
按照圖示進行設(shè)置即可:
設(shè)置完成后點擊更新保存設(shè)置。
接下來配置預(yù)緩存:
檢查是否生效:
有內(nèi)容則緩存成功:(沒有內(nèi)容也不用著急,繼續(xù)往下做)
值得注意的是:一定要開啟專家模式而不是普通模式,經(jīng)測試,普通模式會與接下來要配置的redis插件沖突!
(2)Redis Object Cache
打開開關(guān)即可:
過一段時間有圖像則緩存成功:
5.修改站點偽靜態(tài)
# WP Super Cache rules. # Designed to be included from a 'wordpres企業(yè)網(wǎng)站建設(shè)s-ms-...' configuration file. set $cache_uri $request_uri; # 請求方式為post時不使用緩存 if ($r網(wǎng)站建設(shè)教程equest_method = POST) { set $cache_uri 'null cache'; } if ($query_string != "") { set $cache_uri 'null cache'; } # uri包含以下內(nèi)容時不使用緩存 if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $cache_uri 'null cache'; } # 對登錄用戶或已發(fā)布評論用戶不使用緩存 if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { set $cache_uri 'null cache'; } # START MOBILE # 如果需要在移動端禁用緩存,可以把代碼前的#刪掉 # if ($http_x_wap_profile) { # set $cache_uri 'null cache'; #} #if ($http_profile) { # set $cache_uri 'null cache'; #} #if ($http_user_agent ~* (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800)) { # set $cache_uri 'null cache'; #} #if ($http_user_agent ~* (w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-)) { # set $cache_uri 'null cache'; #} #END MOBILE # 如果存在緩存,則使用緩存,如果沒有緩存,直接轉(zhuǎn)向動態(tài)頁面 location / { try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args ; } rewrite /wp-admin$ $scheme://$host$uri/ permanent;聲明: 本文由我的SEOUC技術(shù)文章主頁發(fā)布于:2023-05-28 ,文章基于Redis Object Cache和WP Super Cache的建站文章主要講述Cache,Redis,wordpress,速度優(yōu)化網(wǎng)站建設(shè)源碼以及服務(wù)器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請保留鏈接: http://www.bifwcx.com/article/web_11812.html