导读:建站技术建站技术WP Rocket缓存插件会自动清除缓存,感觉用了这个缓存插件之后,到处是地雷和各种机关,稍不注意就可能把以前缓存的文章给删了。这种效果对于那些八百年不更新旧文怎么搭建网站建站的技术。
WP Rocket缓存插件会自动清除缓存,感觉用了这个缓存插件之后,到处是地雷和各种机关,稍不注意就可能把以前缓存的文章给删了。这种效果对于那些八百年不更新旧文章的人来说,简直就是灾难啊!幸好WP Rocket插件的官方给出了解决办法,给出了一个叫 wp-rocket-no-cache-auto-purge 的插件,可以禁止WP Rocket自动删除缓存。
插件的主要代码如下所示:
<?php
/ **
* Plugin Name: WP Rocket | Disable Cache Clearing
* Description: Disables all of WP Rocket’s automatic cache clearing.
* Plugin URI: https://github.com/wp-media/wp-rocket-helpers/tree/master/cache/wp-rocket-no-cache-auto-purge/
* Author: WP Rocket Support Team
* Copyright SAS WP MEDIA 2018
* /
namespace WP_Rocket\Helpers\cache\no_cache_auto_purge;
//Standard plugin security, keep this line in place.
defined( 'ABSPATH' ) or die();
/ **
* Remove all of WP Rocket’s cache purging actions.
*
* @author Caspar Hübinger
* /
function remove_purge_hooks() {
//WP core action hooks rocket_clean_domain() gets hooked into.
$clean_domain_hooks = array(
//When user changes the theme
'switch_theme',
//When a user is added
'user_register',
//When a user is updated
'profile_update',
//When a user is deleted
'deleted_user',
//When a custom menu is updated
'wp_update_nav_menu',
//When any theme modifications are updated
'update_option_theme_mods_' . get_option( 'stylesheet' ),
//When you change the order of widgets
'update_option_sidebars_widgets',
//When category permalink prefix is update
'update_option_category_base',
//When tag permalink prefix is update
'update_option_tag_base',
关键词标签: 建站 插件 缓存
声明: 本文由我的SEOUC技术文章主页发布于:2023-07-23 ,文章如何禁止WP Rocket缓存插件自动清除缓存?,建站技主要讲述缓存,插件,建站网站建设源码以及服务器配置搭建相关技术文章。转载请保留链接: https://www.seouc.com/article/web_34769.html