Mercurial > hg > nginx
comparison src/http/modules/proxy/ngx_http_proxy_cache.c @ 177:4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 10 Nov 2003 17:17:31 +0000 |
parents | c0552e5ab567 |
children | a8ff48d26cca |
comparison
equal
deleted
inserted
replaced
176:c0552e5ab567 | 177:4db54fdbcbe7 |
---|---|
300 ngx_http_proxy_finalize_request(p, | 300 ngx_http_proxy_finalize_request(p, |
301 ngx_http_proxy_send_cached_response(p)); | 301 ngx_http_proxy_send_cached_response(p)); |
302 return; | 302 return; |
303 } | 303 } |
304 | 304 |
305 p->state->status = NGX_HTTP_SERVICE_UNAVAILABLE; | |
305 ngx_http_proxy_finalize_request(p, NGX_HTTP_SERVICE_UNAVAILABLE); | 306 ngx_http_proxy_finalize_request(p, NGX_HTTP_SERVICE_UNAVAILABLE); |
306 } | 307 } |
307 | 308 |
308 | 309 |
309 static void ngx_http_proxy_cache_look_complete_request(ngx_http_proxy_ctx_t *p) | 310 static void ngx_http_proxy_cache_look_complete_request(ngx_http_proxy_ctx_t *p) |
466 } | 467 } |
467 | 468 |
468 | 469 |
469 int ngx_http_proxy_is_cachable(ngx_http_proxy_ctx_t *p) | 470 int ngx_http_proxy_is_cachable(ngx_http_proxy_ctx_t *p) |
470 { | 471 { |
471 time_t date, last_modified, expires; | 472 time_t date, last_modified, expires, t; |
472 ngx_http_proxy_headers_in_t *h; | 473 ngx_http_proxy_headers_in_t *h; |
473 | 474 |
474 switch (p->upstream->status) { | 475 switch (p->upstream->status) { |
475 case NGX_HTTP_OK: | 476 case NGX_HTTP_OK: |
476 case NGX_HTTP_MOVED_PERMANENTLY: | 477 case NGX_HTTP_MOVED_PERMANENTLY: |
507 if (h->x_accel_expires) { | 508 if (h->x_accel_expires) { |
508 expires = ngx_atoi(h->x_accel_expires->value.data, | 509 expires = ngx_atoi(h->x_accel_expires->value.data, |
509 h->x_accel_expires->value.len); | 510 h->x_accel_expires->value.len); |
510 if (expires != NGX_ERROR) { | 511 if (expires != NGX_ERROR) { |
511 p->state->reason = NGX_HTTP_PROXY_CACHE_XAE; | 512 p->state->reason = NGX_HTTP_PROXY_CACHE_XAE; |
513 p->state->expires = expires; | |
512 p->cache->ctx.expires = date + expires; | 514 p->cache->ctx.expires = date + expires; |
513 return (expires > 0); | 515 return (expires > 0); |
514 } | 516 } |
515 } | 517 } |
516 | 518 |
521 if (h->expires) { | 523 if (h->expires) { |
522 expires = ngx_http_parse_time(h->expires->value.data, | 524 expires = ngx_http_parse_time(h->expires->value.data, |
523 h->expires->value.len); | 525 h->expires->value.len); |
524 if (expires != NGX_ERROR) { | 526 if (expires != NGX_ERROR) { |
525 p->state->reason = NGX_HTTP_PROXY_CACHE_EXP; | 527 p->state->reason = NGX_HTTP_PROXY_CACHE_EXP; |
528 p->state->expires = expires - date; | |
526 p->cache->ctx.expires = expires; | 529 p->cache->ctx.expires = expires; |
527 return (date < expires); | 530 return (date < expires); |
528 } | 531 } |
529 } | 532 } |
530 } | 533 } |
531 | 534 |
532 if (p->upstream->status == NGX_HTTP_MOVED_PERMANENTLY) { | 535 if (p->upstream->status == NGX_HTTP_MOVED_PERMANENTLY) { |
533 p->state->reason = NGX_HTTP_PROXY_CACHE_MVD; | 536 p->state->reason = NGX_HTTP_PROXY_CACHE_MVD; |
537 p->state->expires = /* STUB: 1 hour */ 60 * 60; | |
534 p->cache->ctx.expires = /* STUB: 1 hour */ 60 * 60; | 538 p->cache->ctx.expires = /* STUB: 1 hour */ 60 * 60; |
535 return 1; | 539 return 1; |
536 } | 540 } |
537 | 541 |
538 if (p->upstream->status == NGX_HTTP_MOVED_TEMPORARILY) { | 542 if (p->upstream->status == NGX_HTTP_MOVED_TEMPORARILY) { |
542 if (last_modified != NGX_ERROR && p->lcf->lm_factor > 0) { | 546 if (last_modified != NGX_ERROR && p->lcf->lm_factor > 0) { |
543 | 547 |
544 /* FIXME: time_t == int_64_t, we can use fpu */ | 548 /* FIXME: time_t == int_64_t, we can use fpu */ |
545 | 549 |
546 p->state->reason = NGX_HTTP_PROXY_CACHE_LMF; | 550 p->state->reason = NGX_HTTP_PROXY_CACHE_LMF; |
547 p->cache->ctx.expires = (time_t) (ngx_time() | 551 t = (time_t) |
548 + (((int64_t) (date - last_modified)) * p->lcf->lm_factor) / 100); | 552 ((((int64_t) (date - last_modified)) * p->lcf->lm_factor) / 100); |
553 p->state->expires = t; | |
554 p->cache->ctx.expires = ngx_time() + t; | |
549 return 1; | 555 return 1; |
550 } | 556 } |
551 | 557 |
552 if (p->lcf->default_expires > 0) { | 558 if (p->lcf->default_expires > 0) { |
553 p->state->reason = NGX_HTTP_PROXY_CACHE_PDE; | 559 p->state->reason = NGX_HTTP_PROXY_CACHE_PDE; |
554 p->cache->ctx.expires = p->lcf->default_expires; | 560 p->state->expires = p->lcf->default_expires; |
561 p->cache->ctx.expires = ngx_time() + p->lcf->default_expires; | |
555 return 1; | 562 return 1; |
556 } | 563 } |
557 | 564 |
558 return 0; | 565 return 0; |
559 } | 566 } |