Skip to content

Commit

Permalink
Fix/avoid serving expired file (#562)
Browse files Browse the repository at this point in the history
* Preventing serving expired cache, when directly serving file

* Preventing serving expired cache, when directly serving file

* Fix spaces in new code

Minor change: Fix indention of new code, and add spaces in code.
  • Loading branch information
viniciusbarros authored and donnchawp committed Jun 15, 2018
1 parent 0137b49 commit bba2622
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function wp_cache_serve_cache_file() {
}
} else { // no $cache_file
global $wpsc_save_headers;
global $cache_max_time;
// last chance, check if a supercache file exists. Just in case .htaccess rules don't work on this host
$filename = supercache_filename();
$file = get_current_url_supercache_dir() . $filename;
Expand All @@ -119,6 +120,9 @@ function wp_cache_serve_cache_file() {
} elseif ( isset( $wpsc_save_headers ) && $wpsc_save_headers ) {
wp_cache_debug( 'Saving headers. Cannot serve a supercache file.' );
return false;
} elseif ( ( filemtime( $file ) + $cache_max_time ) < time() ) {
wp_cache_debug( sprintf( "Cache has expired and is older than %d seconds old.", $cache_max_time ) );
return false;
}

if ( isset( $wp_cache_mfunc_enabled ) == false )
Expand Down

0 comments on commit bba2622

Please sign in to comment.