support Expires in cache
Igor Sysoev
13 years ago
73 | 73 | ngx_table_elt_t *h, ngx_uint_t offset); |
74 | 74 | static ngx_int_t ngx_http_upstream_ignore_header_line(ngx_http_request_t *r, |
75 | 75 | ngx_table_elt_t *h, ngx_uint_t offset); |
76 | static ngx_int_t ngx_http_upstream_process_expires(ngx_http_request_t *r, | |
77 | ngx_table_elt_t *h, ngx_uint_t offset); | |
76 | 78 | static ngx_int_t ngx_http_upstream_process_accel_expires(ngx_http_request_t *r, |
77 | 79 | ngx_table_elt_t *h, ngx_uint_t offset); |
78 | 80 | static ngx_int_t ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, |
191 | 193 | offsetof(ngx_http_headers_out_t, cache_control), 1 }, |
192 | 194 | |
193 | 195 | { ngx_string("Expires"), |
194 | ngx_http_upstream_process_header_line, | |
195 | offsetof(ngx_http_upstream_headers_in_t, expires), | |
196 | ngx_http_upstream_process_expires, 0, | |
196 | 197 | ngx_http_upstream_copy_header_line, |
197 | 198 | offsetof(ngx_http_headers_out_t, expires), 1 }, |
198 | 199 | |
2838 | 2839 | |
2839 | 2840 | |
2840 | 2841 | static ngx_int_t |
2842 | ngx_http_upstream_process_expires(ngx_http_request_t *r, ngx_table_elt_t *h, | |
2843 | ngx_uint_t offset) | |
2844 | { | |
2845 | time_t expires; | |
2846 | ||
2847 | r->upstream->headers_in.expires = h; | |
2848 | ||
2849 | if (r->cache == NULL) { | |
2850 | return NGX_OK; | |
2851 | } | |
2852 | ||
2853 | if (r->cache->valid_sec != 0) { | |
2854 | return NGX_OK; | |
2855 | } | |
2856 | ||
2857 | expires = ngx_http_parse_time(h->value.data, h->value.len); | |
2858 | ||
2859 | if (expires == NGX_ERROR || expires < ngx_time()) { | |
2860 | r->upstream->cacheable = 0; | |
2861 | return NGX_OK; | |
2862 | } | |
2863 | ||
2864 | r->cache->valid_sec = expires; | |
2865 | ||
2866 | return NGX_OK; | |
2867 | } | |
2868 | ||
2869 | ||
2870 | static ngx_int_t | |
2841 | 2871 | ngx_http_upstream_process_accel_expires(ngx_http_request_t *r, |
2842 | 2872 | ngx_table_elt_t *h, ngx_uint_t offset) |
2843 | 2873 | { |