Skip to content

Commit

Permalink
update condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabrisrp committed Jun 12, 2024
1 parent 1c7b9c2 commit 70f0f71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions inc/Engine/Preload/Controller/PreloadUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function preload_url( string $url ) {
}

// Should we perform a duration check?
$check_duration = get_transient( 'rocket_preload_check_duration' ) ? false : true;
$check_duration = ( false === get_transient( 'rocket_preload_check_duration' ) ) ? true : false;

$requests = [
[
Expand Down Expand Up @@ -171,9 +171,9 @@ public function preload_url( string $url ) {
$previous_request_durations = get_transient( 'rocket_preload_previous_request_durations' ) ?? 0;
$previous_request_durations = ( $previous_request_durations <= 0 ) ? $duration : ( $previous_request_durations * 0.7 + $duration * 0.3 );

set_transient( 'rocket_preload_previous_request_durations', $previous_request_durations, 5 * 60 );
set_transient( 'rocket_preload_previous_request_durations', $previous_request_durations, 5 * MINUTE_IN_SECONDS );

set_transient( 'rocket_preload_check_duration', $duration, 60 ); // Don't check request duration for 1 minute.
set_transient( 'rocket_preload_check_duration', $duration, MINUTE_IN_SECONDS ); // Don't check request duration for 1 minute.
$check_duration = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
return [
'shouldDoNothingWhenAlreadyCached' => [
'config' => [
'transient_check_duration' => false,
'transient_check_duration' => 500,
'url' => 'url',
'cache_exists' => true,
'cache_mobile' => false,
Expand All @@ -13,50 +13,50 @@
'timeout' => 0.01,
'user-agent' => 'WP Rocket/Preload',
'sslverify' => false,
]
],
],
]
],
],
'shouldPreloadOnlyOnceWhenMobileCacheDisabled' => [
'config' => [
'transient_check_duration' => false,
'transient_check_duration' => 500,
'url' => 'url',
'cache_exists' => false,
'cache_mobile' => false,
'user_agent' => 'user_agent',
'request' => [
'config' => [
'blocking' => true,
'timeout' => 20,
'blocking' => false,
'timeout' => 0.01,
'user-agent' => 'WP Rocket/Preload',
'sslverify' => false,
]
],
],
],
],
'ShouldPreloadTwiceWhenMobileCacheEnabled' => [
'config' => [
'transient_check_duration' => false,
'transient_check_duration' => 500,
'url' => 'url',
'cache_exists' => false,
'cache_mobile' => true,
'user_agent' => 'user_agent',
'request' => [
'config' => [
'blocking' => true,
'timeout' => 20,
'blocking' => false,
'timeout' => 0.01,
'user-agent' => 'WP Rocket/Preload',
'sslverify' => false,
]
],
],
'request_mobile' => [
'config' => [
'blocking' => false,
'timeout' => 0.01,
'user-agent' => 'user_agent',
'sslverify' => false,
]
],
],
]
]
],
],
];

0 comments on commit 70f0f71

Please sign in to comment.