Add constant for partial cache expiration time

This commit is contained in:
Tetrakern 2024-05-19 17:37:39 +02:00
parent 902e70f418
commit a2778017de
2 changed files with 6 additions and 1 deletions

View File

@ -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
*/

View File

@ -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;
}