From e0bf599995b9e9b3c33ff674edace4107151b9a5 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Tue, 23 Jul 2024 01:47:52 +0200 Subject: [PATCH] Prevent caching of user-specific pages No guarantee, but it should help with some cache plugins. --- singular-bookshelf-ajax.php | 7 +++++++ singular-bookshelf.php | 7 +++++++ user-profile.php | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/singular-bookshelf-ajax.php b/singular-bookshelf-ajax.php index 92ccf23b..a52c600a 100644 --- a/singular-bookshelf-ajax.php +++ b/singular-bookshelf-ajax.php @@ -18,6 +18,13 @@ if ( ! is_user_logged_in() && ! get_option( 'fictioneer_enable_public_cache_comp exit; } +// Try to prevent caching of the page +if ( ! defined( 'DONOTCACHEPAGE' ) ) { + define( 'DONOTCACHEPAGE', true ); +} + +do_action( 'litespeed_control_set_nocache', 'nocache due to user-specific page.' ); + // Setup $current_tab = sanitize_key( $_GET['tab'] ?? '' ); $order = fictioneer_sanitize_query_var( $_GET['order'] ?? 0, ['desc', 'asc'], 'desc' ); diff --git a/singular-bookshelf.php b/singular-bookshelf.php index 15f38c77..b98fad15 100644 --- a/singular-bookshelf.php +++ b/singular-bookshelf.php @@ -18,6 +18,13 @@ if ( ! is_user_logged_in() || get_option( 'fictioneer_enable_public_cache_compat exit; } +// Try to prevent caching of the page +if ( ! defined( 'DONOTCACHEPAGE' ) ) { + define( 'DONOTCACHEPAGE', true ); +} + +do_action( 'litespeed_control_set_nocache', 'nocache due to user-specific page.' ); + // Setup $user = wp_get_current_user(); $current_tab = sanitize_key( $_GET['tab'] ?? '' ); diff --git a/user-profile.php b/user-profile.php index ae12a2e9..fa5ff991 100644 --- a/user-profile.php +++ b/user-profile.php @@ -33,6 +33,13 @@ if ( ! is_user_logged_in() ) { exit; } +// Try to prevent caching of the page +if ( ! defined( 'DONOTCACHEPAGE' ) ) { + define( 'DONOTCACHEPAGE', true ); +} + +do_action( 'litespeed_control_set_nocache', 'nocache due to user-specific page.' ); + // Setup $post_id = get_the_ID(); $current_user = wp_get_current_user();