Changes between Initial Version and Version 1 of Ticket #2309


Ignore:
Timestamp:
01/20/22 14:07:32 (2 years ago)
Author:
yugo-horie.jocdn.co.jp@…
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #2309 – Description

    initial v1  
    11We also have written the same issue in nginx forum.
    2 ngx_http_upstream_process_cache_control in ngx_http_upstream.c
    3 {{{
    4 4738 if (r->cache->valid_sec != 0 && u->headers_in.x_accel_expires != NULL) {
    5 4739 return NGX_OK;
    6 4740 }
    7 4741
    8 4742 start = h->value.data;
    9 4743 last = start + h->value.len;
    10 4744
    11 4745 if (ngx_strlcasestrn(start, last, (u_char *) "no-cache", 8 - 1) != NULL
    12 4746 || ngx_strlcasestrn(start, last, (u_char *) "no-store", 8 - 1) != NULL
    13 4747 || ngx_strlcasestrn(start, last, (u_char *) "private", 7 - 1) != NULL)
    14 4748 {
    15 4749 u->cacheable = 0;
    16 4750 return NGX_OK;
    17 4751 }
    18 }}}
    19 
    20 If Cache-Control from upstream has a value of no-store, no-cache or private, u->cacheable = 0; in ngx_http_upstream_process_cache_control.
    21 
    22 In the case of before processing ngx_http_upstream_process_accel_expires, if it sets u->cacheable = 0 for this procedure, it does not cache according to Cache-Control. X-Accel-Expires is only overwriting valid_sec.
    23 
    24 OTOH, In the case of after processing ngx_http_upstream_process_accel_expires, ngx_http_upstream_process_cache_control returns NGX_OK earlier than the procedure of Cache-Control: no-xxx or private.
    25 In this case, it does cache, the cache is following x-accel-expires values. It ignores Cache-Control.
    26 
    27 As this result it seems not to override entirely Cache-Control by X-Accel-Expires. And It has differential behavor according to order of upstream header.
     2https://forum.nginx.org/read.php?2,219520,293374#msg-293374
     3it seems not to override entirely Cache-Control by X-Accel-Expires. And It has differential behavor according to order of upstream header.
    284
    295We introduced the new flag in upstream.h to identify  whether the specific Cache-Control flags (such as no-store, no-cache, private, stale-while-revalidate, stale-if-error) has already processed before upstream_process_accel_expires, and state of u-> cacheable is also not change  ​unnecessarily.