Mercurial > hg > nginx-quic
comparison src/http/ngx_http_upstream.c @ 2663:09725d69cb25
support X-Accel-Expires in cache
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 03 Apr 2009 14:33:34 +0000 |
parents | 40f9def49ed5 |
children | f903114355d4 |
comparison
equal
deleted
inserted
replaced
2662:40f9def49ed5 | 2663:09725d69cb25 |
---|---|
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_accel_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_limit_rate(ngx_http_request_t *r, | 79 static ngx_int_t ngx_http_upstream_process_limit_rate(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_buffering(ngx_http_request_t *r, | 81 static ngx_int_t ngx_http_upstream_process_buffering(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_charset(ngx_http_request_t *r, | 83 static ngx_int_t ngx_http_upstream_process_charset(ngx_http_request_t *r, |
212 { ngx_string("X-Powered-By"), | 214 { ngx_string("X-Powered-By"), |
213 ngx_http_upstream_ignore_header_line, 0, | 215 ngx_http_upstream_ignore_header_line, 0, |
214 ngx_http_upstream_copy_header_line, 0, 0 }, | 216 ngx_http_upstream_copy_header_line, 0, 0 }, |
215 | 217 |
216 { ngx_string("X-Accel-Expires"), | 218 { ngx_string("X-Accel-Expires"), |
217 ngx_http_upstream_process_header_line, | 219 ngx_http_upstream_process_accel_expires, |
218 offsetof(ngx_http_upstream_headers_in_t, x_accel_expires), | 220 offsetof(ngx_http_upstream_headers_in_t, x_accel_expires), |
219 ngx_http_upstream_copy_header_line, 0, 0 }, | 221 ngx_http_upstream_copy_header_line, 0, 0 }, |
220 | 222 |
221 { ngx_string("X-Accel-Redirect"), | 223 { ngx_string("X-Accel-Redirect"), |
222 ngx_http_upstream_process_header_line, | 224 ngx_http_upstream_process_header_line, |
1912 } | 1914 } |
1913 | 1915 |
1914 if (u->cacheable) { | 1916 if (u->cacheable) { |
1915 time_t now, valid; | 1917 time_t now, valid; |
1916 | 1918 |
1917 valid = ngx_http_file_cache_valid(u->conf->cache_valid, | 1919 now = ngx_time(); |
1918 u->headers_in.status_n); | 1920 |
1921 valid = r->cache->valid_sec; | |
1922 | |
1923 if (valid == 0) { | |
1924 valid = ngx_http_file_cache_valid(u->conf->cache_valid, | |
1925 u->headers_in.status_n); | |
1926 if (valid) { | |
1927 r->cache->valid_sec = now + valid; | |
1928 } | |
1929 } | |
1930 | |
1919 if (valid) { | 1931 if (valid) { |
1920 | |
1921 now = ngx_time(); | |
1922 | |
1923 r->cache->valid_sec = now + valid; | |
1924 | |
1925 r->cache->last_modified = r->headers_out.last_modified_time; | 1932 r->cache->last_modified = r->headers_out.last_modified_time; |
1926 r->cache->date = now; | 1933 r->cache->date = now; |
1927 r->cache->body_start = (u_short) (u->buffer.pos - u->buffer.start); | 1934 r->cache->body_start = (u_short) (u->buffer.pos - u->buffer.start); |
1928 | 1935 |
1929 if (r->headers_out.content_length_n != -1) { | 1936 if (r->headers_out.content_length_n != -1) { |
2830 return NGX_OK; | 2837 return NGX_OK; |
2831 } | 2838 } |
2832 | 2839 |
2833 | 2840 |
2834 static ngx_int_t | 2841 static ngx_int_t |
2842 ngx_http_upstream_process_accel_expires(ngx_http_request_t *r, | |
2843 ngx_table_elt_t *h, ngx_uint_t offset) | |
2844 { | |
2845 u_char *p; | |
2846 size_t len; | |
2847 ngx_int_t n; | |
2848 | |
2849 r->upstream->headers_in.x_accel_expires = h; | |
2850 | |
2851 if (r->cache == NULL) { | |
2852 return NGX_OK; | |
2853 } | |
2854 | |
2855 len = h->value.len; | |
2856 p = h->value.data; | |
2857 | |
2858 if (p[0] != '@') { | |
2859 n = ngx_atoi(p, len); | |
2860 | |
2861 switch (n) { | |
2862 case 0: | |
2863 r->upstream->cacheable = 0; | |
2864 break; | |
2865 | |
2866 case NGX_ERROR: | |
2867 break; | |
2868 | |
2869 default: | |
2870 r->cache->valid_sec = ngx_time() + n; | |
2871 break; | |
2872 } | |
2873 | |
2874 } else { | |
2875 p++; | |
2876 len--; | |
2877 | |
2878 n = ngx_atoi(p, len); | |
2879 | |
2880 if (n != NGX_ERROR) { | |
2881 r->cache->valid_sec = n; | |
2882 } | |
2883 } | |
2884 | |
2885 return NGX_OK; | |
2886 } | |
2887 | |
2888 | |
2889 static ngx_int_t | |
2835 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, | 2890 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, |
2836 ngx_uint_t offset) | 2891 ngx_uint_t offset) |
2837 { | 2892 { |
2838 ngx_int_t n; | 2893 ngx_int_t n; |
2839 | 2894 |