Skip to content

Commit

Permalink
Super Cache: remove the minimum preload interval based on post count …
Browse files Browse the repository at this point in the history
…(#37618)

* Remove the complicated "post count and preload interval" code.

Let them preload the cache as often as they want

* changelog

* Make the name of this filter clearer

* Add "_interval" to function names too.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9362569224

Upstream-Ref: Automattic/jetpack@267fed3
  • Loading branch information
donnchawp authored and matticbot committed Jun 4, 2024
1 parent ad7456e commit 524040f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ This is an alpha version! The changes listed here are not final.
- Super Cache: tell user that Cache module of Boost must be deactivated to use WPSC
- Updated package dependencies.

### Fixed
- Super Cache: remove the preload interval based on the post count. Preload as often as you want.

## [1.12.1] - 2024-05-09
### Changed
- General: update WordPress version requirements to WordPress 6.4. [#37047]
Expand Down
7 changes: 2 additions & 5 deletions partials/preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
}

$count = wpsc_post_count();
if ( $count > 1000 ) {
$min_refresh_interval = 720;
} else {
$min_refresh_interval = 30;
}

$min_refresh_interval = wpsc_get_minimum_preload_interval();

echo '<div class="wpsc-card">';
echo '<p>' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '</p>';
Expand Down
30 changes: 14 additions & 16 deletions wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1062,13 +1062,7 @@ function toggleLayer( whichLayer ) {
if ( 'preload' === $curr_tab ) {
if ( true == $super_cache_enabled && ! defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;
$count = wpsc_post_count();
if ( $count > 1000 ) {
$min_refresh_interval = 720;
} else {
$min_refresh_interval = 30;
}
wpsc_preload_settings( $min_refresh_interval );
wpsc_preload_settings();
$currently_preloading = false;

echo '<div id="wpsc-preload-status"></div>';
Expand Down Expand Up @@ -3945,7 +3939,18 @@ function wpsc_post_count() {

return $count;
}
function wpsc_preload_settings( $min_refresh_interval = 'NA' ) {

/**
* Get the minimum interval in minutes between preload refreshes.
* Filter the default value of 10 minutes using the `wpsc_minimum_preload_interval` filter.
*
* @return int
*/
function wpsc_get_minimum_preload_interval() {
return apply_filters( 'wpsc_minimum_preload_interval', 10 );
}

function wpsc_preload_settings() {
global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;

if ( isset( $_POST[ 'action' ] ) == false || $_POST[ 'action' ] != 'preload' )
Expand All @@ -3965,14 +3970,7 @@ function wpsc_preload_settings( $min_refresh_interval = 'NA' ) {
return;
}

if ( $min_refresh_interval == 'NA' ) {
$count = wpsc_post_count();
if ( $count > 1000 ) {
$min_refresh_interval = 720;
} else {
$min_refresh_interval = 30;
}
}
$min_refresh_interval = wpsc_get_minimum_preload_interval();

// Set to true if the preload interval is changed, and a reschedule is required.
$force_preload_reschedule = false;
Expand Down

0 comments on commit 524040f

Please sign in to comment.