Klaus Demo nginx / c8298bf
support Expires in cache Igor Sysoev 13 years ago
1 changed file(s) with 32 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
7373 ngx_table_elt_t *h, ngx_uint_t offset);
7474 static ngx_int_t ngx_http_upstream_ignore_header_line(ngx_http_request_t *r,
7575 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);
7678 static ngx_int_t ngx_http_upstream_process_accel_expires(ngx_http_request_t *r,
7779 ngx_table_elt_t *h, ngx_uint_t offset);
7880 static ngx_int_t ngx_http_upstream_process_limit_rate(ngx_http_request_t *r,
191193 offsetof(ngx_http_headers_out_t, cache_control), 1 },
192194
193195 { 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,
196197 ngx_http_upstream_copy_header_line,
197198 offsetof(ngx_http_headers_out_t, expires), 1 },
198199
28382839
28392840
28402841 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
28412871 ngx_http_upstream_process_accel_expires(ngx_http_request_t *r,
28422872 ngx_table_elt_t *h, ngx_uint_t offset)
28432873 {