bdaebd
diff --git a/modules/cache/cache_util.h b/modules/cache/cache_util.h
bdaebd
index 6b92151..4c42a8e 100644
bdaebd
--- a/modules/cache/cache_util.h
bdaebd
+++ b/modules/cache/cache_util.h
bdaebd
@@ -195,6 +195,9 @@ typedef struct {
bdaebd
     unsigned int store_nostore_set:1;
bdaebd
     unsigned int enable_set:1;
bdaebd
     unsigned int disable_set:1;
bdaebd
+    /* treat maxex as hard limit */
bdaebd
+    unsigned int hardmaxex:1;
bdaebd
+    unsigned int hardmaxex_set:1;
bdaebd
 } cache_dir_conf;
bdaebd
 
bdaebd
 /* A linked-list of authn providers. */
bdaebd
diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c
bdaebd
index 56a09f5..41015b5 100644
bdaebd
--- a/modules/cache/mod_cache.c
bdaebd
+++ b/modules/cache/mod_cache.c
bdaebd
@@ -1455,6 +1455,11 @@ static apr_status_t cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
bdaebd
             exp = date + dconf->defex;
bdaebd
         }
bdaebd
     }
bdaebd
+    /* else, forcibly cap the expiry date if required */
bdaebd
+    else if (dconf->hardmaxex && (date + dconf->maxex) < exp) {
bdaebd
+        exp = date + dconf->maxex;
bdaebd
+    }        
bdaebd
+
bdaebd
     info->expire = exp;
bdaebd
 
bdaebd
     /* We found a stale entry which wasn't really stale. */
bdaebd
@@ -1954,7 +1959,9 @@ static void *create_dir_config(apr_pool_t *p, char *dummy)
bdaebd
 
bdaebd
     /* array of providers for this URL space */
bdaebd
     dconf->cacheenable = apr_array_make(p, 10, sizeof(struct cache_enable));
bdaebd
-
bdaebd
+    /* flag; treat maxex as hard limit */
bdaebd
+    dconf->hardmaxex = 0;
bdaebd
+    dconf->hardmaxex_set = 0;
bdaebd
     return dconf;
bdaebd
 }
bdaebd
 
bdaebd
@@ -2004,7 +2011,10 @@ static void *merge_dir_config(apr_pool_t *p, void *basev, void *addv) {
bdaebd
     new->enable_set = add->enable_set || base->enable_set;
bdaebd
     new->disable = (add->disable_set == 0) ? base->disable : add->disable;
bdaebd
     new->disable_set = add->disable_set || base->disable_set;
bdaebd
-
bdaebd
+    new->hardmaxex = 
bdaebd
+        (add->hardmaxex_set == 0)
bdaebd
+        ? base->hardmaxex
bdaebd
+        : add->hardmaxex;
bdaebd
     return new;
bdaebd
 }
bdaebd
 
bdaebd
@@ -2332,12 +2342,18 @@ static const char *add_cache_disable(cmd_parms *parms, void *dummy,
bdaebd
 }
bdaebd
 
bdaebd
 static const char *set_cache_maxex(cmd_parms *parms, void *dummy,
bdaebd
-                                   const char *arg)
bdaebd
+                                   const char *arg, const char *hard)
bdaebd
 {
bdaebd
     cache_dir_conf *dconf = (cache_dir_conf *)dummy;
bdaebd
 
bdaebd
     dconf->maxex = (apr_time_t) (atol(arg) * MSEC_ONE_SEC);
bdaebd
     dconf->maxex_set = 1;
bdaebd
+    
bdaebd
+    if (hard && strcasecmp(hard, "hard") == 0) {
bdaebd
+        dconf->hardmaxex = 1;
bdaebd
+        dconf->hardmaxex_set = 1;
bdaebd
+    }
bdaebd
+
bdaebd
     return NULL;
bdaebd
 }
bdaebd
 
bdaebd
@@ -2545,7 +2561,7 @@ static const command_rec cache_cmds[] =
bdaebd
                    "caching is enabled"),
bdaebd
     AP_INIT_TAKE1("CacheDisable", add_cache_disable, NULL, RSRC_CONF|ACCESS_CONF,
bdaebd
                   "A partial URL prefix below which caching is disabled"),
bdaebd
-    AP_INIT_TAKE1("CacheMaxExpire", set_cache_maxex, NULL, RSRC_CONF|ACCESS_CONF,
bdaebd
+    AP_INIT_TAKE12("CacheMaxExpire", set_cache_maxex, NULL, RSRC_CONF|ACCESS_CONF,
bdaebd
                   "The maximum time in seconds to cache a document"),
bdaebd
     AP_INIT_TAKE1("CacheMinExpire", set_cache_minex, NULL, RSRC_CONF|ACCESS_CONF,
bdaebd
                   "The minimum time in seconds to cache a document"),