From 2c0f3c9457b1de508b52b46c2a7bfadd364d0f03 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Sun, 16 Mar 2003 21:49:33 +0000
Subject: [PATCH] - Cache improvement: only flush cache when told to.

---
 includes/common.inc          | 16 +++-------------
 modules/system.module        |  4 +---
 modules/system/system.module |  4 +---
 3 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/includes/common.inc b/includes/common.inc
index 92672926f73b..57b79055d329 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -643,15 +643,6 @@ function cache_clear_all($cid = NULL) {
   }
 }
 
-function cache_clear_old($cid = NULL) {
-  if (empty($cid)) {
-    db_query("DELETE FROM cache WHERE expire < ". time() ." AND expire > 0");
-  }
-  else {
-    db_query("DELETE FROM cache WHERE cid = '%s' AND expire < %s AND expire > 0", $cid, time());
-  }
-}
-
 function page_set_cache() {
   global $user, $REQUEST_METHOD;
 
@@ -666,10 +657,9 @@ function page_get_cache() {
   global $user, $REQUEST_METHOD;
 
   if (!$user->uid && $REQUEST_METHOD == "GET") {
-    if ($cache = cache_get(request_uri())) {
-      cache_clear_old();
-    }
-    else {
+    $cache = cache_get(request_uri());
+
+    if (empty($cache)) {
       ob_start();
     }
   }
diff --git a/modules/system.module b/modules/system.module
index eafee55c514d..6d70f9bfe40c 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -83,9 +83,7 @@ function system_view_general() {
 
   // caching:
   $output .= "<h3>". t("Cache settings") ."</h3>\n";
-  $period = array(10 => format_interval(10), 20 => format_interval(20), 30 => format_interval(30), 40 => format_interval(40), 50 => format_interval(50), 50 => format_interval(50), 60 => format_interval(60), 90 => format_interval(90), 120 => format_interval(120), 150 => format_interval(150), 180 => format_interval(180), 210 => format_interval(210), 240 => format_interval(240), 270 => format_interval(270), 300 => format_interval(300), 360 => format_interval(360), 420 => format_interval(420), 480 => format_interval(480), 540 => format_interval(540), 600 => format_interval(600), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200));
-  $output .= form_select(t("Cache support"), "cache", variable_get("cache", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable the caching of pages."));
-  $output .= form_select(t("Discard cached pages older than"), "cache_clear", variable_get("cache_clear", 120), $period, t("The time cached pages should be kept.  Older pages are automatically refreshed."));
+  $output .= form_select(t("Cache support"), "cache", variable_get("cache", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable the caching of rendered pages.  When caching is enabled, Drupal will flush the cache when required to make sure updates take effect immediately."));
   $output .= "<hr />\n";
 
   // submission settings:
diff --git a/modules/system/system.module b/modules/system/system.module
index eafee55c514d..6d70f9bfe40c 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -83,9 +83,7 @@ function system_view_general() {
 
   // caching:
   $output .= "<h3>". t("Cache settings") ."</h3>\n";
-  $period = array(10 => format_interval(10), 20 => format_interval(20), 30 => format_interval(30), 40 => format_interval(40), 50 => format_interval(50), 50 => format_interval(50), 60 => format_interval(60), 90 => format_interval(90), 120 => format_interval(120), 150 => format_interval(150), 180 => format_interval(180), 210 => format_interval(210), 240 => format_interval(240), 270 => format_interval(270), 300 => format_interval(300), 360 => format_interval(360), 420 => format_interval(420), 480 => format_interval(480), 540 => format_interval(540), 600 => format_interval(600), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200));
-  $output .= form_select(t("Cache support"), "cache", variable_get("cache", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable the caching of pages."));
-  $output .= form_select(t("Discard cached pages older than"), "cache_clear", variable_get("cache_clear", 120), $period, t("The time cached pages should be kept.  Older pages are automatically refreshed."));
+  $output .= form_select(t("Cache support"), "cache", variable_get("cache", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable the caching of rendered pages.  When caching is enabled, Drupal will flush the cache when required to make sure updates take effect immediately."));
   $output .= "<hr />\n";
 
   // submission settings:
-- 
GitLab