httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
Subject svn commit: r369811 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_cache.xml modules/cache/mod_cache.c modules/cache/mod_cache.h
Date Tue, 17 Jan 2006 15:12:29 GMT
Author: rpluem
Date: Tue Jan 17 07:12:23 2006
New Revision: 369811

URL: http://svn.apache.org/viewcvs?rev=369811&view=rev
Log:
* Add CacheMinExpire directive to set the minimum time in seconds to cache a document
  in the case that no valid expire time was supplied with the document.

Submitted by: Brian Akins <brian.akins turner.com>
Reviewed by: Ruediger Pluem

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/mod/mod_cache.xml
    httpd/httpd/trunk/modules/cache/mod_cache.c
    httpd/httpd/trunk/modules/cache/mod_cache.h

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/CHANGES?rev=369811&r1=369810&r2=369811&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Jan 17 07:12:23 2006
@@ -2,6 +2,10 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) mod_cache: Add CacheMinExpire directive to set the minimum time in
+     seconds to cache a document.
+     [Brian Akins <brian.akins turner.com>, Ruediger Pluem]
+
   *) mod_cache: Make caching of reverse proxies possible again. PR 38017.
      [Ruediger Pluem]
 

Modified: httpd/httpd/trunk/docs/manual/mod/mod_cache.xml
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/docs/manual/mod/mod_cache.xml?rev=369811&r1=369810&r2=369811&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_cache.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_cache.xml Tue Jan 17 07:12:23 2006
@@ -212,6 +212,26 @@
 </directivesynopsis>
 
 <directivesynopsis>
+<name>CacheMinExpire</name>
+<description>The minimum time in seconds to cache a document</description>
+<syntax>CacheMinExpire <var>seconds</var></syntax>
+<default>CacheMinExpire 0</default>
+<contextlist><context>server config</context><context>virtual host</context>
+</contextlist>
+
+<usage>
+    <p>The <directive>CacheMinExpire</directive> directive specifies the
minimum number of
+    seconds for which cachable HTTP documents will be retained without checking the origin
+    server. This is only used if no valid expire time was supplied with the document.</p>
+
+
+    <example>
+      CacheMinExpire 3600
+    </example>
+</usage>
+</directivesynopsis>
+
+<directivesynopsis>
 <name>CacheDefaultExpire</name>
 <description>The default duration to cache a document when no expiry date is specified.</description>
 <syntax>CacheDefaultExpire <var>seconds</var></syntax>

Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=369811&r1=369810&r2=369811&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Tue Jan 17 07:12:23 2006
@@ -689,6 +689,9 @@
         if ((lastmod != APR_DATE_BAD) && (lastmod < date)) {
             apr_time_t x = (apr_time_t) ((date - lastmod) * conf->factor);
 
+            if (x < conf->minex) {
+                x = conf->minex;
+            }
             if (x > conf->maxex) {
                 x = conf->maxex;
             }
@@ -872,6 +875,8 @@
     /* maximum time to cache a document */
     ps->maxex = DEFAULT_CACHE_MAXEXPIRE;
     ps->maxex_set = 0;
+    ps->minex = DEFAULT_CACHE_MINEXPIRE;
+    ps->minex_set = 0;
     /* default time to cache a document */
     ps->defex = DEFAULT_CACHE_EXPIRE;
     ps->defex_set = 0;
@@ -908,6 +913,7 @@
                                        overrides->cacheenable);
     /* maximum time to cache a document */
     ps->maxex = (overrides->maxex_set == 0) ? base->maxex : overrides->maxex;
+    ps->minex = (overrides->minex_set == 0) ? base->minex : overrides->minex;
     /* default time to cache a document */
     ps->defex = (overrides->defex_set == 0) ? base->defex : overrides->defex;
     /* factor used to estimate Expires date from LastModified date */
@@ -1082,6 +1088,19 @@
     return NULL;
 }
 
+static const char *set_cache_minex(cmd_parms *parms, void *dummy,
+                                   const char *arg)
+{
+    cache_server_conf *conf;
+
+    conf =
+        (cache_server_conf *)ap_get_module_config(parms->server->module_config,
+                                                  &cache_module);
+    conf->minex = (apr_time_t) (atol(arg) * MSEC_ONE_SEC);
+    conf->minex_set = 1;
+    return NULL;
+}
+
 static const char *set_cache_defex(cmd_parms *parms, void *dummy,
                                    const char *arg)
 {
@@ -1144,6 +1163,8 @@
                   "A partial URL prefix below which caching is disabled"),
     AP_INIT_TAKE1("CacheMaxExpire", set_cache_maxex, NULL, RSRC_CONF,
                   "The maximum time in seconds to cache a document"),
+    AP_INIT_TAKE1("CacheMinExpire", set_cache_minex, NULL, RSRC_CONF,
+                  "The minimum time in seconds to cache a document"),
     AP_INIT_TAKE1("CacheDefaultExpire", set_cache_defex, NULL, RSRC_CONF,
                   "The default time in seconds to cache a document"),
     AP_INIT_FLAG("CacheIgnoreNoLastMod", set_cache_ignore_no_last_mod, NULL,

Modified: httpd/httpd/trunk/modules/cache/mod_cache.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/cache/mod_cache.h?rev=369811&r1=369810&r2=369811&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.h (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.h Tue Jan 17 07:12:23 2006
@@ -84,6 +84,7 @@
 #define MSEC_ONE_MIN    ((apr_time_t)(60*APR_USEC_PER_SEC))    /* one minute, in microseconds
*/
 #define MSEC_ONE_SEC    ((apr_time_t)(APR_USEC_PER_SEC))       /* one second, in microseconds
*/
 #define DEFAULT_CACHE_MAXEXPIRE MSEC_ONE_DAY
+#define DEFAULT_CACHE_MINEXPIRE 0
 #define DEFAULT_CACHE_EXPIRE    MSEC_ONE_HR
 #define DEFAULT_CACHE_LMFACTOR  (0.1)
 
@@ -150,6 +151,9 @@
     #define CACHE_IGNORE_HEADERS_SET   1
     #define CACHE_IGNORE_HEADERS_UNSET 0
     int ignore_headers_set;
+    /* Minimum time to keep cached files in msecs */
+    apr_time_t minex;
+    int minex_set;
 } cache_server_conf;
 
 /* cache info information */



Mime
View raw message