给WordPress添加一个Super Cache静态缓冲插件
我们知道wordpress在做页面显示的时侯会加载很多东西,对于一个文章我们在写好后很少会去再次修改,这样就没有必要每次在显示的时候都要加载这些东西,直接将之前加载处理的东西输出就好了。
如果我们能够将wordpress页面内容做缓冲甚至做成静态化,也就是单纯的html页面,那将会带来速度的提升。给网站的服务器减少很多负载,性能效率方面大为优化。
WP Super Cache这款插件就能够实现WordPress页面数据缓冲并可以静态化页面,他是在WP-Cache plugin插件的基础上修改的,功能更强大。他能够在你的服务器端生成缓冲静态的web页面,这样下次访客访问的时候,就直接提供这些缓存的静态页面,wordpress就不用重新执行加载处理的脚本,性能大大优化。
下载地址:WP super cache
安装方法
- 将下载解压好的文件上传到plugins目录下,在后台中激活它,如果失败可以先按卸载方法处理,然后安装
- 在Wordpress的后台中启用它
- 如果缺少.htaccess文件,自己建立一下
WordPress目录下的-
RewriteEngine On
-
RewriteBase /
-
-
RewriteCond %{REQUEST_METHOD} !=POST
-
RewriteCond %{QUERY_STRING} !.*=.*
-
RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
-
RewriteCond %{HTTP:Accept-Encoding} gzip
-
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
-
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]
-
-
RewriteCond %{REQUEST_METHOD} !=POST
-
RewriteCond %{QUERY_STRING} !.*=.*
-
RewriteCond %{QUERY_STRING} !.*attachment_id=.*
-
RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
-
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
-
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
-
-
RewriteCond %{REQUEST_FILENAME} !-f
-
RewriteCond %{REQUEST_FILENAME} !-d
-
RewriteRule . /index.php [L]
wp-content/cache目录下的
-
# BEGIN supercache
-
<IfModule mod_mime.c>
-
AddEncoding gzip .gz
-
AddType text/html .gz
-
</IfModule>
-
<IfModule mod_deflate.c>
-
SetEnvIfNoCase Request_URI \.gz$ no-gzip
-
</IfModule>
-
<IfModule mod_headers.c>
-
Header set Cache-Control 'max-age=300, must-revalidate'
-
</IfModule>
-
<IfModule mod_expires.c>
-
ExpiresActive On
-
ExpiresByType text/html A300
-
</IfModule>
-
-
# END supercache
-
验证是否安装成功
打开网页,右键浏览器菜单=>查看页面代码,在最后面应该可以看到如下内容
第一次缓冲
-
<!– Dynamic Page Served (once) in 1.404 seconds –>
输出缓冲的内容
-
<!– Dynamic Page Served (once) in 1.404 seconds –>
-
<!– Cached page served by WP-Super-Cache –>
卸载方法
- 1. 在后台禁用此插件。
- 2. 删除/wp-content/plugins/目录的wp-super-cache目录。
- 3. 删除wp-content目录下面的cache目录。
- 4. 删除wp-content目录下面的wp-config.php ,advanced-cache.php两个文件。
- 5. 修改wp-config.php,把包含如下信息的一行删掉即可:define(’WP_CACHE’, true);
Popularity: 7% [?]
Related
Comments
No Responses to “给WordPress添加一个Super Cache静态缓冲插件”
有帮助了
[Reply]