中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

10步教你來優(yōu)化WordPress速度 為服務器和訪客減壓

2019-03-21    來源:wg369.com

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用

wordpress很強大,但是強大之余也有一堆爛攤子要使用者收拾,那就是較高的服務器占用,和速度實在不咋滴。如果你用wordpress來做CMS站點那么你如果用主機托管那么一定杯具了,用VPS內(nèi)存小了寬帶小了也麻煩。其他人都是教了一招,這次我匯集百家所長,十招齊發(fā),十管齊下,勇者無敵!

大家多說時間就是生命,可能幾秒鐘的等待就會讓網(wǎng)站失去一個訪客,對于網(wǎng)站的速度你不能等!

1.Cookie的靜態(tài)化制作

約有80%至90%的時間,訪客要花費大量的時間等你的WordPress加載靜態(tài)內(nèi)容。這意味著,有大部分的時間,用戶瀏覽您的網(wǎng)站,他們正在等待加載,如:圖像,CSS,JS腳本,flash等等。所以你可以優(yōu)化內(nèi)容,更快捷地讓WordPress加載一個cookie域。消除了負載時的一些珍貴的時間,當然了這可能看起來并不多,但添加其他拖延問題時,才能真正減少時間損失。

我不知道其他源碼的網(wǎng)站應該怎么做,但是wordpress很簡單只要修改一下wp-config.php就好了!

在合適的位置加入:

define("WP_CONTENT_URL", "http://static.***.com");

define("COOKIE_DOMAIN", "www.***.com");

然后用“bloginfo(template_directory')”這段代碼加入你要實現(xiàn)的靜態(tài)內(nèi)容中即可!

2.設置靜態(tài)內(nèi)容的緩存

靜態(tài)的內(nèi)容緩存,我就不多介紹了,你用相關的緩存插件也需要這個步驟,那就是修改.htaccess文件

代碼如下:

<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault      "access plus 1 month"
# cache.appcache needs re-requests
# in FF 3.6 (thx Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Your document html
ExpiresByType text/html "access plus 0 seconds"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
# RSS feed
ExpiresByType application/rss+xml "access plus 1 hour"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 week"
# Media: images, video, audio
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# HTC files  (css3pie)
ExpiresByType text/x-component "access plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff   "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
# CSS and JavaScript
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
<IfModule mod_headers.c>
Header append Cache-Control "public"
</IfModule>
</IfModule>

 3.優(yōu)化數(shù)據(jù)庫

有一個方法來為的服務器減壓,怎樣才能優(yōu)化wordpress的數(shù)據(jù)庫呢?自然是用代碼,用代碼,嘿嘿,你可能編輯了幾個小時都沒有效果!WordPress的免費插件使得這個問題變得簡單,個人推薦Yoast Optimize DB和WP DB Manager。牢記大多數(shù)緩存插件還幫助了很多本,所以你會發(fā)現(xiàn)大多數(shù)正在采取照顧您已經(jīng)現(xiàn)存的緩存軟件的工作量。

4.盡量緩存媒體

創(chuàng)建緩存可以很簡單地通過插件完成。從本質(zhì)上講,這些新增轉(zhuǎn)成靜態(tài)頁面,所有這些方式,既方便加載,又節(jié)省您的瀏覽器前端的滯后。那么,什么插件,聽我的建議吧。

我最喜歡的緩存工具:WP Super Cache, Hyper Cache,和W3 Total Cache。用這些生成HTML文件,可以節(jié)省更多的時間。

5.使用CDN

CDN加速目前很火,那么自然火是有一定的道理的,因為CDN可以加速呀。呵呵,cdn一般是收費,不過免費的CDN也有。

下面為大家推薦一些實用的免費CDN:

免費CDN:Webluker,cloudflare

6.壓縮JS和CSS文件

你可能只聽過說JS和CSS文件的庫轉(zhuǎn)移,總沒有聽說過壓縮吧。呵呵,這個方法是很異想天開,但是就是有人做到了,并且開發(fā)了壓縮的實用工具,當然機器的壓縮并不盡人意,你也可以手工壓縮。

JS壓縮工具推薦:Closure Compiler ,Minify JavaScript. CSS壓縮工具推薦:Minify CSS ,CSS Compressor

7.壓縮圖像

圖像的加載也是比較耗時的,想你如果試用BMP或者PSD作為圖像那么速度一定和蝸牛爬一樣,比較高質(zhì)量保存的PNG文件我也不怎么推薦。建議試用JPG壓縮,但是也不要過度!不然圖片會失真。

通過WP Smush.it插件你可以比較簡單的來壓縮圖片!

8.GZIP壓縮

GZIP的壓縮在一定限度內(nèi)是很不錯的!而且通過gzip壓縮不僅能夠加速而且還可以屏蔽廣告(免費空間的福音。〨ZIP的壓縮代碼交給你!修改.htaccess文件

<IfModule mod_deflate.c>
# force deflate for mangled headers
# developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)s*,?s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
<IfModule filter_module>
FilterDeclare   COMPRESS
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/html
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/css
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/plain
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/x-component
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/javascript
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/json
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xhtml+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/rss+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/atom+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/vnd.ms-fontobject
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/svg+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/x-font-ttf
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $font/opentype
FilterChain     COMPRESS
FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
</IfModule>
<IfModule !mod_filter.c>
# Legacy versions of Apache
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</IfModule>
</IfModule>

 9.禁用ETAGS

ETAGS可能我也搞不懂,但是你僅用了它就可以加速了,所以你管他神馬ETAGS你說是不?

在.htaccess 文件中+這一行!

File ETag none

 10.服務器環(huán)境

使用LAMP環(huán)境或者LNMP環(huán)境,可以更好的支持wordpress并且風險系數(shù)低,也很安全,估計你的服務器或者VPS幾年都不會重啟一次,所以網(wǎng)上總是我自己的linux密碼忘記了重啟怎么辦! 這就是免費惹的禍,真是躺著也中槍啊!

總結(jié):

這些方法中大多數(shù)只適合在LAMP或者LNMP的環(huán)境下,所以使用wordpress就必須要在linux環(huán)境下,win環(huán)境下的wordpress你會遇到一些列的問題!

本文來自:米飯維谷 教程餐廳組 | http://www.wg369.com/archives/1989.html

標簽: WordPress速度優(yōu)化 WordPress插件 數(shù)據(jù) 庥嘔

版權(quán)申明:本站文章部分自網(wǎng)絡,如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:六月百度排名與收錄“大地震”的原因與對策探究

下一篇:Google排名優(yōu)化圣經(jīng)