From a2778017de1c03d86065df18e2c6feb0863c25e3 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Sun, 19 May 2024 17:37:39 +0200 Subject: [PATCH] Add constant for partial cache expiration time --- functions.php | 5 +++++ includes/functions/_service-caching.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index c9e0fc61..0e2be4c2 100644 --- a/functions.php +++ b/functions.php @@ -288,6 +288,11 @@ if ( ! defined( 'FICTIONEER_PATREON_EXPIRATION_TIME' ) ) { define( 'FICTIONEER_PATREON_EXPIRATION_TIME', WEEK_IN_SECONDS ); } +// Integer: Time until a cached partial expired +if ( ! defined( 'FICTIONEER_PARTIAL_CACHE_EXPIRATION_TIME' ) ) { + define( 'FICTIONEER_PARTIAL_CACHE_EXPIRATION_TIME', 4 * HOUR_IN_SECONDS ); +} + /* * Booleans */ diff --git a/includes/functions/_service-caching.php b/includes/functions/_service-caching.php index c7a65a1e..29043e3d 100644 --- a/includes/functions/_service-caching.php +++ b/includes/functions/_service-caching.php @@ -893,7 +893,7 @@ function fictioneer_get_cached_partial( $slug, $identifier = '', $expiration = n if ( file_exists( $path ) ) { $filemtime = filemtime( $path ); - if ( time() - $filemtime < ( $expiration ?? DAY_IN_SECONDS ) ) { + if ( time() - $filemtime < ( $expiration ?? FICTIONEER_PARTIAL_CACHE_EXPIRATION_TIME ) ) { echo file_get_contents( $path ); return; }