<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>Hello,</div><div>I am on nginx-1.7.1 & trying to use nginx's page caching feature but run into an issue for responses with a valid 'Expires' header which seem to be in the correct rfc 1123 compliant format. Nginx somehow doesn't like it & hence doesn't cache such responses. Is this a bug ?</div><div><br data-mce-bogus="1"></div><div>----------------------------------------------------------</div><div>Config in http block to enable page caching</div><div>----------------------------------------------------------</div><div>proxy_cache_path /opt/zimbra/data/tmp/nginx/cache keys_zone=zimbra:10m;<br> proxy_cache zimbra;<br> proxy_cache_key "$scheme$request_method$host$request_uri";<br> proxy_cache_valid 200 302 10m;<br>add_header X-Proxy-Cache $upstream_cache_status;</div><div><br data-mce-bogus="1"></div><div><div style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" data-mce-style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><strong style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" data-mce-style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">------------------------------------------------------------------------------------------------------</strong><br></div><div style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" data-mce-style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><strong>Logs showing that a .css with a valid Expires header doesn't get cached because of header parsing failure</strong></div><div style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" data-mce-style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><strong style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" data-mce-style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">------------------------------------------------------------------------------------------------------</strong><br></div></div><div>2015/03/10 13:58:29 [debug] 17311#0: *7 http upstream request: "/css/images,common,dwt,msgview,login,zm,spellcheck,skin.css?v=150302053859&debug=false&skin=harmony&locale=en_US"<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http upstream send request handler<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http upstream send request<br>2015/03/10 13:58:29 [debug] 17311#0: *7 chain writer in: 0000000000000000<br>2015/03/10 13:58:29 [debug] 17311#0: *7 event timer: 21, old: 1426013969478, new: 1426013969533<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http upstream process header<br>2015/03/10 13:58:29 [debug] 17311#0: *7 SSL_read: 3904<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy status 200 "200 OK"<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy header: "Date: Tue, 10 Mar 2015 18:58:29 GMT"<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy header: "X-Frame-Options: SAMEORIGIN"<br><strong>2015/03/10 13:58:29 [debug] 17311#0: *7 ngx_http_parse_time failed: h->value.data = Thu, 9 Apr 2015 19:58:29 GMT, h->value.len = 28   </strong><br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy header: "Expires: Thu, 9 Apr 2015 19:58:29 GMT"<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy header: "Cache-Control: public, max-age=2595600"<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy header: "Vary: User-Agent"<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy header: "Content-Type: text/css"<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy header: "Vary: Accept-Encoding, User-Agent"<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy header: "Content-Length: 295693"<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http proxy header done<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http script var: "MISS"</div><div>2015/03/10 13:58:29 [debug] 17311#0: *7 spdy header filter<br>2015/03/10 13:58:29 [debug] 17311#0: *7 malloc: 00000000025EB460:385<br>2015/03/10 13:58:29 [debug] 17311#0: *7 spdy deflate out: ni:00000000025EB5C8 no:00000000025D780E ai:0 ao:56 rc:0<br>2015/03/10 13:58:29 [debug] 17311#0: *7 spdy:3 create SYN_REPLY frame 00000000025D7858: len:374<br>2015/03/10 13:58:29 [debug] 17311#0: *7 http cleanup add: 00000000025D7898<br><strong>2015/03/10 13:58:29 [debug] 17311#0: *7 http cacheable: 0</strong></div><div><strong><br data-mce-bogus="1"></strong></div><div>Code added in src/http/ngx_http_upstream.c to throw the 'ngx_http_parse_time failed' debug</div><div><p class="p1" style="margin: 0px;" data-mce-style="margin: 0px;">expires = ngx_http_parse_time(h->value.data, h->value.len);   ---> Returns <span style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;" data-mce-style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">NGX_ERROR</span></p><p class="p2" style="margin: 0px;" data-mce-style="margin: 0px;"><br></p><p class="p1" style="margin: 0px;" data-mce-style="margin: 0px;"><span class="Apple-converted-space">    </span><span class="s1">if</span> (expires == NGX_ERROR || expires < ngx_time()) {</p><p class="p1" style="margin: 0px;" data-mce-style="margin: 0px;"><span class="Apple-converted-space">        </span><strong>ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,</strong></p><p class="p3" style="margin: 0px;" data-mce-style="margin: 0px;"><strong><span class="s2"><span class="Apple-converted-space">                           </span></span>"ngx_http_parse_time failed: h->value.data = %s, h->value.len = %d"<span class="s2">,</span></strong></p><p class="p1" style="margin: 0px;" data-mce-style="margin: 0px;"><strong><span class="Apple-converted-space">                           </span>h->value.data, h->value.len);</strong></p><p class="p1" style="margin: 0px;" data-mce-style="margin: 0px;"><span class="Apple-converted-space">        </span>u->cacheable = 0;   ---> sets cacheable to 0 here & hence does not gets cached</p><p class="p1" style="margin: 0px;" data-mce-style="margin: 0px;"><span class="Apple-converted-space">        </span><span class="s1">return</span> NGX_OK;</p><p class="p1" style="margin: 0px;" data-mce-style="margin: 0px;"><span class="Apple-converted-space">    </span>}</p><p class="p1" style="margin: 0px;" data-mce-style="margin: 0px;"><br></p></div><div><strong>------------------------------------------------------------------------------------------------------</strong></div><div><strong>Logs showing that a gif image without Expires header gets cached correctly</strong></div><div><strong style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" data-mce-style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">------------------------------------------------------------------------------------------------------</strong><br></div><div>2015/03/10 13:58:35 [debug] 17311#0: *7 http upstream request: "/service/zimlet/com_zimbra_email/img/EmailZimlet_busy.gif?"<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http upstream process header<br>2015/03/10 13:58:35 [debug] 17311#0: *7 SSL_read: 899<br>2015/03/10 13:58:35 [debug] 17311#0: *7 SSL_read: -1<br>2015/03/10 13:58:35 [debug] 17311#0: *7 SSL_get_error: 2<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http proxy status 200 "200 OK"<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http proxy header: "Date: Tue, 10 Mar 2015 18:58:35 GMT"<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http proxy header: "Content-Type: image/gif"<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http proxy header: "Last-Modified: Tue, 03 Mar 2015 01:41:21 GMT"<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http proxy header: "Accept-Ranges: bytes"<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http proxy header: "Content-Length: 729"<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http proxy header done<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http ims:1425346881 lm:1425346881<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http script var: "MISS"<br>2015/03/10 13:58:35 [debug] 17311#0: *7 spdy header filter<br>2015/03/10 13:58:35 [debug] 17311#0: *7 malloc: 00000000025C92B0:181<br>2015/03/10 13:58:35 [debug] 17311#0: *7 spdy deflate out: ni:00000000025C9365 no:000000000260ECBB ai:0 ao:31 rc:0<br>2015/03/10 13:58:35 [debug] 17311#0: *7 spdy:39 create SYN_REPLY frame 000000000260ECF0: len:195<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http cleanup add: 000000000260ED30<br>2015/03/10 13:58:35 [debug] 17311#0: *7 spdy frame out: 000000000260ECF0 sid:39 prio:5 bl:1 len:195<br>2015/03/10 13:58:35 [debug] 17311#0: *7 SSL buf copy: 203<br>2015/03/10 13:58:35 [debug] 17311#0: *7 SSL to write: 203<br>2015/03/10 13:58:35 [debug] 17311#0: *7 SSL_write: 203<br>2015/03/10 13:58:35 [debug] 17311#0: *7 spdy:39 SYN_REPLY frame 000000000260ECF0 was sent<br>2015/03/10 13:58:35 [debug] 17311#0: *7 spdy frame sent: 000000000260ECF0 sid:39 bl:1 len:195<br>2015/03/10 13:58:35 [debug] 17311#0: *7 http file cache set header<br><strong>2015/03/10 13:58:35 [debug] 17311#0: *7 http cacheable: 1</strong></div><div><strong><br data-mce-bogus="1"></strong></div><div>Thanks</div><div>-Kunal</div></div></body></html>