MEDIUM: cache: max-age configuration keyword

Add a configuration keyword to change the max-age.
The default one is still 60s.
diff --git a/src/cache.c b/src/cache.c
index 3447038..3b19f85 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -326,7 +326,7 @@
  *  - the default-max-age of the cache
  *
  */
-int http_calc_maxage(struct stream *s)
+int http_calc_maxage(struct stream *s, struct cache *cache)
 {
 	struct http_txn *txn = s->txn;
 	struct hdr_ctx ctx;
@@ -335,8 +335,6 @@
 	int maxage = -1;
 
 
-	/* TODO: forced maxage configuration */
-
 	ctx.idx = 0;
 
 	/* loop on the Cache-Control values */
@@ -367,14 +365,12 @@
 
 
 	if (smaxage > 0)
-		return smaxage;
+		return MIN(smaxage, cache->maxage);
 
 	if (maxage > 0)
-		return maxage;
-
-	/* TODO: return default value */
+		return MIN(maxage, cache->maxage);
 
-	return 60;
+	return cache->maxage;
 
 }
 
@@ -402,7 +398,8 @@
 	struct filter *filter;
 	struct hdr_ctx ctx;
 	struct shared_block *first = NULL;
-	struct shared_context *shctx = shctx_ptr((struct cache *)rule->arg.act.p[0]);
+	struct cache *cache = (struct cache *)rule->arg.act.p[0];
+	struct shared_context *shctx = shctx_ptr(cache);
 	struct cache_entry *object;
 
 
@@ -484,7 +481,7 @@
 					/* Insert the node later on caching success */
 
 					shctx_lock(shctx);
-					if (entry_exist((struct cache *)rule->arg.act.p[0], txn->cache_hash)) {
+					if (entry_exist(cache, txn->cache_hash)) {
 						shctx_unlock(shctx);
 						if (filter->ctx) {
 							object->eb.key = 0;
@@ -497,8 +494,7 @@
 
 					/* store latest value and expiration time */
 					object->latest_validation = now.tv_sec;
-					object->expire = now.tv_sec + http_calc_maxage(s);
-
+					object->expire = now.tv_sec + http_calc_maxage(s, cache);
 				}
 				return ACT_RET_CONT;
 			}
@@ -765,7 +761,7 @@
 					   file, linenum, tmp_cache_config->id);
 				err_code |= ERR_WARN;
 			}
-
+			tmp_cache_config->maxage = 60;
 			tmp_cache_config->maxblocks = 0;
 		}
 	} else if (strcmp(args[0], "total-max-size") == 0) {
@@ -780,6 +776,19 @@
 		maxsize = atoi(args[1]) * 1024 * 1024 / CACHE_BLOCKSIZE;
 		tmp_cache_config->maxblocks = maxsize;
 
+	} else if (strcmp(args[0], "max-age") == 0) {
+		if (alertif_too_many_args(1, file, linenum, args, &err_code)) {
+			err_code |= ERR_ABORT;
+			goto out;
+		}
+
+		if (!*args[1]) {
+			ha_warning("parsing [%s:%d]: '%s' expects an age parameter in seconds.\n",
+			        file, linenum, args[0]);
+			err_code |= ERR_WARN;
+		}
+
+		tmp_cache_config->maxage = atoi(args[1]);
 	} else if (*args[0] != 0) {
 		ha_alert("parsing [%s:%d] : unknown keyword '%s' in 'cache' section\n", file, linenum, args[0]);
 		err_code |= ERR_ALERT | ERR_FATAL;