乐在分享 | 智在交流
www.picqu.com

wordpress缓存加速优化插件 WP Rocket[更新至v2.9.9汉化版]及配置教程

WP Rocket是当前最高效也是最灵活的WordPress静态缓存插件。可以优化你的JS CSS文件结构减少多次请求达到优化速度的目的,还集成了图片延迟加载对最求极致加速的用户不错的选择,通过使用这个插件,能使得你的WordPress博客将显著的提速。

自动页面缓存
为每个访问的地址创建一个超高速缓存文件
预加载缓存
图片延迟加载
静态文件压缩优化合并JS和CSS文件
通过缩小减少了HTML、JavaScript和CSS文件请求,加快加载时间
开发人员可以很容易地使高级定制跟多强大的优化功能
WP火箭发射后激活——最小的配置,取得立竿见影的效果

WP Rocket v2.9.9官方版本更新日志如下:
2.9.9 (2017年3月22日更新)
Enhancement: Compatibility with GoDaddy Managed Hosting
Enhancement: Update Mobile_Detect class to recent version
Enhancement: Allow caching when the ao_noptimize query string is set
Fix: LazyLoad Iframes & Videos no longer crashes Android Facebook browser
Fix: CDN URL no longer applied on SVG URL by reference
Fix: Remove query string is now correctly applied when minification disabled on a single post
Fix: Imagify install button works again
我们已经对其进行了汉化处理,方便您直接投入项目使用。与人方便之原则,然而这一切都是免费的!记住,免费的!

关于 WP Rocket 配置

第一种情况:web服务器是Apache,直接点开设置,常规配置如下图

如上图,压缩部分不用动!只要按如上图配置即可,高级选项不用动,如果有使用CDN的,按照CDN配置去做。一样的。上图已经基
本满足了一般网站了,没有极致的,小到一个js都要压缩,没什么意义。差不多速度上去了就可以了。
第二种情况:web服务器是Nginx
稍稍复杂一点点,需要添加rewite规则到vhost配置文件中。目的就是让web服务器节省在请求动态文件,直接读取生成的静态文件。
事实上节省时间不少。
1、下载安装 WP Rocket (下载地址往下看),39 刀正版支持,诸位老板少抽几包烟,尽量支持官方。
2、添加rewite规则到vhost配置文件中。目的就是让web服务器节省在请求动态文件,直接读取生成的静态文件。

###################################################################################################
# Rocket-Nginx
#
# Rocket-Nginx is a NGINX configuration to speedup your WordPress
# website with the cache plugin WP-Rocket (http://wp-rocket.me)
#
# Author: Maxime Jobin
# URL: https://github.com/maximejobin/rocket-nginx
#
# Tested with WP-Rocket version: 2.6.15
# Tested with NGINX: 1.8.0 (stable)
#
# Version 1.1
#
###################################################################################################

set $rocket_debug 0;				# Add debug information into header
set $rocket_hsts_value "";			# HTTP Strict Transport Security (to overwrite default) 

###################################################################################################
# Do not alter theses values
#
set $rocket_bypass 1;				# Should NGINX bypass WordPress and call cache file directly ?
set $rocket_encryption "";			# Is GZIP accepted by client ?
set $rocket_file "";				# Filename to use
set $rocket_is_bypassed "No";		# Header text added to check if the bypass worked or not. Header: X-Rocket-Nginx-Bypass
set $rocket_reason "";				# Reason why cache file was not used. If cache file is used, what file was used
set $rocket_https_prefix "";		# HTTPS prefix to use when cached files are using HTTPS
set $rocket_hsts 0;					# Is HSTS is off (0) by default. Will be turned on (1) if request is HTTPS

# HSTS Default value : 1 year, include subdomains.
set $rocket_hsts_value_default "max-age=31536000; includeSubDomains";

###################################################################################################
# PAGE CACHE
#

# Is GZIP accepted by client ?
if ($http_accept_encoding ~ gzip) {
	set $rocket_encryption "_gzip";
}

# Is SSL request ?
if ($https = "on") {
	set $rocket_https_prefix "-https";
	set $rocket_hsts 1;
}

# If HSTS value is not set, use default value
if ($rocket_hsts_value = "") {
	set $rocket_hsts_value "$rocket_hsts_value_default";
}

# If HSTS is disabled, unset HSTS set for Rocket-Nginx configuration
if ($rocket_hsts = "0") {
	set $rocket_hsts_value "";
}

# File/URL to return IF we must bypass WordPress
set $rocket_url "/wp-content/cache/wp-rocket/$http_host/$request_uri/index$rocket_https_prefix.html$rocket_encryption";
set $rocket_file "$document_root$rocket_url";


# Do not bypass if it's a POST request
if ($request_method = POST) {
	set $rocket_bypass 0;
	set $rocket_reason "POST request";
}

# Do not bypass if arguments are found (e.g. ?page=2)
if ($args != "") {
	set $rocket_bypass 0;
	set $rocket_reason "Arguments found";
}

# Do not bypass if the site is in maintenance mode
if (-f "$document_root/.maintenance") {
	set $rocket_bypass 0;
	set $rocket_reason "Maintenance mode";
}

# Do not bypass if one of those cookie if found
# wordpress_logged_in_[hash] : When a user is logged in, this cookie is created (we'd rather let WP-Rocket handle that)
# wp-postpass_[hash] : When a protected post requires a password, this cookie is created.
if ($http_cookie ~* "(wordpress_logged_in_|wp\-postpass_)") {
	set $rocket_bypass 0;
	set $rocket_reason "Cookie";
}

# Do not bypass if the cached file does not exist
if (!-f "$rocket_file") {
	set $rocket_bypass 0;
	set $rocket_reason "File not cached";
}

# If the bypass token is still on, let's bypass WordPress with the cached URL
if ($rocket_bypass = 1) {
	set $rocket_is_bypassed "Yes";
	set $rocket_reason "$rocket_url";
}

# Clear variables if debug is not needed
if ($rocket_debug = 0) {
	set $rocket_reason "";
	set $rocket_file "";
}

# If the bypass token is still on, rewrite according to the file linked to the request
if ($rocket_bypass = 1) {
	rewrite .* "$rocket_url" last;
}

# Add header to HTML cached files
location ~ /wp-content/cache/wp-rocket/.*html$ {
	add_header Vary "Accept-Encoding, Cookie";
	add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
	add_header X-Rocket-Nginx-Reason $rocket_reason;
	add_header X-Rocket-Nginx-File $rocket_file;
	add_header Strict-Transport-Security "$rocket_hsts_value";
	expires 30d;
}

# Do not gzip cached files that are already gzipped
location ~ /wp-content/cache/wp-rocket/.*_gzip$ {
	gzip off;
	types {}
	default_type text/html;
	add_header Content-Encoding gzip;
	add_header Vary "Accept-Encoding, Cookie";
	add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
	add_header X-Rocket-Nginx-Reason $rocket_reason;
	add_header X-Rocket-Nginx-File $rocket_file;
	add_header Strict-Transport-Security "$rocket_hsts_value";
	expires 30d;
}

# Debug header (when file is not cached)
add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
add_header X-Rocket-Nginx-Reason $rocket_reason;
add_header X-Rocket-Nginx-File $rocket_file;

# No HSTS header added here. We suppose it's correctly added in the site configuration


###################################################################################################
# BROWSER CSS CACHE
#
location ~ /wp-content/cache/min/.*\.css$ {
	gzip_vary on;
	expires max;
}


###################################################################################################
# BROWSER JS CACHE
#
location ~ /wp-content/cache/min/.*\.js$ {
	gzip_vary on;
	expires max;
}


###################################################################################################
# BROWSER MEDIA CACHE
#
location ~* \.(ico|gif|jpe?g|png|svg|eot|otf|woff|woff2|ttf|ogg)$ {
	expires max;
}

记住以上代码复制保存为 rocket.conf 文件上传到你的 nginx/conf 目录中,然后我们只要在我们的vhsot文件中引入即可。

# BEGIN WP rocket

include /usr/local/nginx/conf/rocket.conf;

# END WP rocket

然后 Nginx restart 重启一下使文件生效。按照如上配置好之后,查看网站源码,源码最底部就会出现安装成功后的提示如下:
ok,nginx -t测试一把,不用测试,本站在用的。按照如上配置之后,查看网站源码,就会出现安装成功后的提示!

<!-- This website is like a Rocket, isn't it ? Performance optimized by WP Rocket. Learn more: http://wp-rocket.me - Debug: [email protected] -->

在检查前,先退出您的网站。除非您启用了“为登录用户建立缓存。”这个选项(在基本选项卡里)。如果没有启用,对于登录用户,是无法看到缓存页面的。

文件下载

  文件名称:wordpress缓存加速优化插件WP Rocket V2.9.2英文版  文件大小:1MB
  下载声明:
  下载地址:WP Rocket V2.9.2英文版 密码:v64r

WP Rocket V2.9.5汉化版链接:http://pan.baidu.com/s/1qYJbGOs 密码:gdm8
WP Rocket V2.9.8.1汉化版链接:http://pan.baidu.com/s/1kVju1Af 密码:28cs

演示下载

点击下载 本位置文字版广告位招商,有意请联系! 查看演示
未经允许不得转载:图趣|PicQu » wordpress缓存加速优化插件 WP Rocket[更新至v2.9.9汉化版]及配置教程
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!