From ea30bf8adc3329d04ee45a4484d80036a6c893a9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 30 Mar 2022 01:56:47 +0200 Subject: [PATCH 1/4] use more cache. Speeds up page builds --- inc/functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index ab43210b..5457cc5f 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1690,6 +1690,14 @@ function buildIndex($global_api = "yes") { if (!$content) break; + if ($config['cache']['enabled']) { + $contentHash = md5(json_encode($content['threads'])); + $cacheHit = cache::get('index_cache'. $contentHash); + if ($cacheHit) + continue; + cache::set('index_cache'. $contentHash, "processed", 3600); + } + // json api if ($config['api']['enabled']) { $threads = $content['threads']; -- 2.25.1 From 868821f24c03889a058222d5a5184687ca9d8260 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 30 Mar 2022 02:27:34 +0200 Subject: [PATCH 2/4] new strat --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index 5457cc5f..895a3adb 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1691,7 +1691,7 @@ function buildIndex($global_api = "yes") { break; if ($config['cache']['enabled']) { - $contentHash = md5(json_encode($content['threads'])); + $contentHash = md5(json_encode($content['body'])); $cacheHit = cache::get('index_cache'. $contentHash); if ($cacheHit) continue; -- 2.25.1 From c7db5d54665c1dd2dd14cd3fb5db6ad1baff7803 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 31 Mar 2022 01:40:04 +0200 Subject: [PATCH 3/4] fixed bugs --- inc/functions.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 895a3adb..b80e2c63 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1690,12 +1690,19 @@ function buildIndex($global_api = "yes") { if (!$content) break; + // Tries to avoid rebuilding if the body is the same as the one in cache. if ($config['cache']['enabled']) { $contentHash = md5(json_encode($content['body'])); - $cacheHit = cache::get('index_cache'. $contentHash); - if ($cacheHit) + $contentHashKey = '_index_hashed_'. $board . '_' . $page; + $cachedHash = cache::get($contentHashKey); + if ($cachedHash == $contentHash){ + if ($config['api']['enabled']) { + // this is needed for the thread.json and catalog.json rebuilding below, which includes all pages. + $catalog[$page-1] = $content['threads']; + } continue; - cache::set('index_cache'. $contentHash, "processed", 3600); + } + cache::set($contentHashKey, $contentHash, 3600); } // json api -- 2.25.1 From 914c5b3c63113b7096114648e1922ed98d068fb7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 31 Mar 2022 01:46:40 +0200 Subject: [PATCH 4/4] fixed bugs --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index b80e2c63..1ff9768a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1693,7 +1693,7 @@ function buildIndex($global_api = "yes") { // Tries to avoid rebuilding if the body is the same as the one in cache. if ($config['cache']['enabled']) { $contentHash = md5(json_encode($content['body'])); - $contentHashKey = '_index_hashed_'. $board . '_' . $page; + $contentHashKey = '_index_hashed_'. $board['uri'] . '_' . $page; $cachedHash = cache::get($contentHashKey); if ($cachedHash == $contentHash){ if ($config['api']['enabled']) { -- 2.25.1