近几天测试了一下WordPress headless,数据不多用simply-static生成插件全站生成html,发现了几个问题:1、生成是通过一条条链接抓取,所以必须配合sitemap才能完全抓取
2、生成效率提升较难,得加大php time-out时间,闲时生成。服务器经常直接挂了,php开memcached,卸载woocommerce才解决,还是用强悍云数据库,如果本地mysql估计非常卡顿。
3、除了single页面,page、category、tag也要设置成html后缀,避免大量的文件夹,但是分页有问题,导致大量生成错误,全站的/page/No/要变成/page-No.html才能实现)。- function 17513_custom_page_rules() {global $wp_rewrite;$wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%.html';$wp_rewrite->extra_permastructs['post_tag']['with_front'] = '';$wp_rewrite->extra_permastructs['post_tag']['struct'] = $wp_rewrite->extra_permastructs['post_tag']['with_front'] . 'tag/%post_tag%.html';$wp_rewrite->extra_permastructs['category']['with_front'] = 'category';$wp_rewrite->extra_permastructs['category']['struct'] = $wp_rewrite->extra_permastructs['category']['with_front'].'/%category%.html';} add_action( 'init', '17513_custom_page_rules' );
复制代码 4、cdn回源+WP SUPER CACHER插件的触发缓存,还是比较理想且高效的。 |