Add constant for partial cache expiration time
This commit is contained in:
parent
902e70f418
commit
a2778017de
@ -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
|
||||
*/
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user