SaHtmlCache 介绍
Typecho HTML 静态缓存插件 SaHtmlCache V1.0.0 发布
我这个老博客文章比较多,为了节省服务器资源,减少数据库读写次数,于是就花了点时间,做了typecho第一个插件
同一个页面先看一下启用前和启用后的差别
未启用缓存加载页面需要3.94s
启用缓存后加载页面需要1.49s
服务器配置高的话,基本上感觉不到差距,但是网站访问量大了之后,服务器资源就很紧缺了,节省一半的时间效果还是很明显的哇,哈哈哈
SaHtmlCache 下载
SaHtmlCache 安装方法
1、将SaHtmlCache.rar 解压后上传于站点/usr/plugins/目录下
2、PHP.ini环境配置文件要改一下,将allow_url_include = On
3、永久链接(伪静态)设置为/{cid}.html (目前是通过文章编号cid生成文件的,如果想生成个性化文件名,请自行修改一下插件生成文件名)
4、将cache目录设为可读可写,Linux是777权限
5、修改站点根目录下index.php,添加以下代码
/* SaHtmlCach 重定向到HTML静态文件 / $safile = $_SERVER['REQUEST_URI']; if(strpos($safile,'comment')<1){ if ($safile=='/'||$safile=='index.php'){ $safile = 'index.html'; } $sahtmlfile = './usr/plugins/SaHtmlCache/cache/'.$safile; if(file_exists($sahtmlfile)){ include($sahtmlfile); exit; } }
如图所示
6、后台启用插件,并生成HTML文件
伪静态设置参考
帮助说明
1、如何区分HTML缓存是否生效?
查看网页源代码,如果顶部有SaCache created 2020/01/04 04:33:14代码,说明已经成功,如图所示
2、搜索功能是否影响?
不影响博客搜索页
3、分类目录页是否可以缓存?
暂时不支持
4、评论页是否支持HMTL缓存?
支持,需要定期生成HMTL文件
5、为何生成HTML比较卡?
全站生成HTML慎用,比较耗服务器资源,不过一劳永逸,耐心等待吧
6、我是否可以修改代码?
可以随便修改代码!
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /var/www/html/usr/themes/armx/functions.php on line 769
Warning: get_headers(): Failed to enable crypto in /var/www/html/usr/themes/armx/functions.php on line 769
Warning: get_headers(https://avatar.zrahh.com/avatar/031445342bdef37475328fb1e9e6b346?d=404): failed to open stream: operation failed in /var/www/html/usr/themes/armx/functions.php on line 769
Windows 7Chrome 83.0.4103.106
楼主,怎么无法评论哈
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /var/www/html/usr/themes/armx/functions.php on line 769
Warning: get_headers(): Failed to enable crypto in /var/www/html/usr/themes/armx/functions.php on line 769
Warning: get_headers(https://avatar.zrahh.com/avatar/031445342bdef37475328fb1e9e6b346?d=404): failed to open stream: operation failed in /var/www/html/usr/themes/armx/functions.php on line 769
Windows 7Chrome 83.0.4103.106
收藏了,正需要
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /var/www/html/usr/themes/armx/functions.php on line 769
Warning: get_headers(): Failed to enable crypto in /var/www/html/usr/themes/armx/functions.php on line 769
Warning: get_headers(https://avatar.zrahh.com/avatar/031445342bdef37475328fb1e9e6b346?d=404): failed to open stream: operation failed in /var/www/html/usr/themes/armx/functions.php on line 769
Windows 7Chrome 83.0.4103.106
收藏了,正需要