diff src/http/modules/ngx_http_headers_filter_module.c @ 238:a528ae0fe909 NGINX_0_4_4

nginx 0.4.4 *) Feature: the $scheme variable. *) Feature: the "expires" directive supports the "max" parameter. *) Feature: the "include" directive supports the "*" mask. Thanks to Jonathan Dance. *) Bugfix: the "return" directive always overrode the "error_page" response code redirected by the "error_page" directive. *) Bugfix: a segmentation fault occurred if zero-length body was in PUT method. *) Bugfix: the redirect was changed incorrectly if the variables were used in the "proxy_redirect" directive.
author Igor Sysoev <http://sysoev.ru>
date Mon, 02 Oct 2006 00:00:00 +0400
parents c982febb7588
children 5bef04fc3fd5
line wrap: on
line diff
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -26,6 +26,7 @@ typedef struct {
 #define NGX_HTTP_EXPIRES_UNSET   -2147483647
 #define NGX_HTTP_EXPIRES_OFF     -2147483646
 #define NGX_HTTP_EXPIRES_EPOCH   -2147483645
+#define NGX_HTTP_EXPIRES_MAX     -2147483644
 
 
 static void *ngx_http_headers_create_conf(ngx_conf_t *cf);
@@ -177,6 +178,13 @@ ngx_http_headers_filter(ngx_http_request
             cc->value.len = sizeof("no-cache") - 1;
             cc->value.data = (u_char *) "no-cache";
 
+        } else if (conf->expires == NGX_HTTP_EXPIRES_MAX) {
+            expires->value.data = (u_char *) "Thu, 31 Dec 2037 23:55:55 GMT";
+
+            /* 10 years */
+            cc->value.len = sizeof("max-age=315360000") - 1;
+            cc->value.data = (u_char *) "max-age=315360000";
+
         } else {
             expires->value.data = ngx_palloc(r->pool, len);
             if (expires->value.data == NULL) {
@@ -349,6 +357,11 @@ ngx_http_headers_expires(ngx_conf_t *cf,
         return NGX_CONF_OK;
     }
 
+    if (ngx_strcmp(value[1].data, "max") == 0) {
+        hcf->expires = NGX_HTTP_EXPIRES_MAX;
+        return NGX_CONF_OK;
+    }
+
     if (ngx_strcmp(value[1].data, "off") == 0) {
         hcf->expires = NGX_HTTP_EXPIRES_OFF;
         return NGX_CONF_OK;