Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
define('PAGE_CACHE_EXPIRES', 10000);
define('PAGE_CACHE_FILEPATH', './.cached_stats.html');

define('PAGE_CACHE_DEBUG', false);

// Get the modification time of the cached page and
// determine if it is within the expiration time
$cached = filemtime(PAGE_CACHE_FILEPATH);
$expired = ($cached !== false && $cached > (microtime(true) - PAGE_CACHE_EXPIRES));
if (!$expired) {
if (PAGE_CACHE_DEBUG) error_log('Serving cached stats page');
echo file_get_contents(PAGE_CACHE_FILEPATH);
exit();
}
} else if (!PAGE_CACHE_DEBUG) error_log('Generating new stats page');

ob_start();

Expand Down