comparison src/http/ngx_http_upstream.c @ 2666:81556a9b6488

support Expires in cache
author Igor Sysoev <igor@sysoev.ru>
date Fri, 03 Apr 2009 15:48:19 +0000
parents 4d627567c324
children c1ac00c2bc75
comparison
equal deleted inserted replaced
2665:4d627567c324 2666:81556a9b6488
72 static ngx_int_t 72 static ngx_int_t
73 ngx_http_upstream_process_multi_header_lines(ngx_http_request_t *r, 73 ngx_http_upstream_process_multi_header_lines(ngx_http_request_t *r,
74 ngx_table_elt_t *h, ngx_uint_t offset); 74 ngx_table_elt_t *h, ngx_uint_t offset);
75 static ngx_int_t ngx_http_upstream_ignore_header_line(ngx_http_request_t *r, 75 static ngx_int_t ngx_http_upstream_ignore_header_line(ngx_http_request_t *r,
76 ngx_table_elt_t *h, ngx_uint_t offset); 76 ngx_table_elt_t *h, ngx_uint_t offset);
77 static ngx_int_t ngx_http_upstream_process_expires(ngx_http_request_t *r,
78 ngx_table_elt_t *h, ngx_uint_t offset);
77 static ngx_int_t ngx_http_upstream_process_accel_expires(ngx_http_request_t *r, 79 static ngx_int_t ngx_http_upstream_process_accel_expires(ngx_http_request_t *r,
78 ngx_table_elt_t *h, ngx_uint_t offset); 80 ngx_table_elt_t *h, ngx_uint_t offset);
79 static ngx_int_t ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, 81 static ngx_int_t ngx_http_upstream_process_limit_rate(ngx_http_request_t *r,
80 ngx_table_elt_t *h, ngx_uint_t offset); 82 ngx_table_elt_t *h, ngx_uint_t offset);
81 static ngx_int_t ngx_http_upstream_process_buffering(ngx_http_request_t *r, 83 static ngx_int_t ngx_http_upstream_process_buffering(ngx_http_request_t *r,
190 offsetof(ngx_http_upstream_headers_in_t, cache_control), 192 offsetof(ngx_http_upstream_headers_in_t, cache_control),
191 ngx_http_upstream_copy_multi_header_lines, 193 ngx_http_upstream_copy_multi_header_lines,
192 offsetof(ngx_http_headers_out_t, cache_control), 1 }, 194 offsetof(ngx_http_headers_out_t, cache_control), 1 },
193 195
194 { ngx_string("Expires"), 196 { ngx_string("Expires"),
195 ngx_http_upstream_process_header_line, 197 ngx_http_upstream_process_expires, 0,
196 offsetof(ngx_http_upstream_headers_in_t, expires),
197 ngx_http_upstream_copy_header_line, 198 ngx_http_upstream_copy_header_line,
198 offsetof(ngx_http_headers_out_t, expires), 1 }, 199 offsetof(ngx_http_headers_out_t, expires), 1 },
199 200
200 { ngx_string("Accept-Ranges"), 201 { ngx_string("Accept-Ranges"),
201 ngx_http_upstream_process_header_line, 202 ngx_http_upstream_process_header_line,
2837 return NGX_OK; 2838 return NGX_OK;
2838 } 2839 }
2839 2840
2840 2841
2841 static ngx_int_t 2842 static ngx_int_t
2843 ngx_http_upstream_process_expires(ngx_http_request_t *r, ngx_table_elt_t *h,
2844 ngx_uint_t offset)
2845 {
2846 time_t expires;
2847
2848 r->upstream->headers_in.expires = h;
2849
2850 if (r->cache == NULL) {
2851 return NGX_OK;
2852 }
2853
2854 if (r->cache->valid_sec != 0) {
2855 return NGX_OK;
2856 }
2857
2858 expires = ngx_http_parse_time(h->value.data, h->value.len);
2859
2860 if (expires == NGX_ERROR || expires < ngx_time()) {
2861 r->upstream->cacheable = 0;
2862 return NGX_OK;
2863 }
2864
2865 r->cache->valid_sec = expires;
2866
2867 return NGX_OK;
2868 }
2869
2870
2871 static ngx_int_t
2842 ngx_http_upstream_process_accel_expires(ngx_http_request_t *r, 2872 ngx_http_upstream_process_accel_expires(ngx_http_request_t *r,
2843 ngx_table_elt_t *h, ngx_uint_t offset) 2873 ngx_table_elt_t *h, ngx_uint_t offset)
2844 { 2874 {
2845 u_char *p; 2875 u_char *p;
2846 size_t len; 2876 size_t len;