<div dir="ltr"><img width="0" height="0" class="mailtrack-img" alt="" style="display:flex" src="https://mailtrack.io/trace/mail/f79d75398a26222876e07ab2e9fb1171893daf40.png?u=74734"><div>


















<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif">That’s the tricky part. These MISSes are intermittent. Whenever
I run curl I get HITs but I end up seeing a lot of MISS in the logs. <span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span> </span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif">How do I log these MiSSes with the reason? I want to know
what headers ended up bypassing the cache.<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span> </span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif">Here’s my caching config<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span> </span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>  </span><span>          </span>proxy_pass <a href="http://127.0.0.1:8000">http://127.0.0.1:8000</a>;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_set_header X-Real-IP<span> 
</span>$remote_addr;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>             </span><span>   </span>proxy_set_header X-Forwarded-Proto https;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_set_header X-Forwarded-Port 443;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span> </span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>                </span># If
logged in, don't cache.<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>                </span>if
($http_cookie ~*
"comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>            </span><span>      </span>set $do_not_cache 1;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>                </span>}<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_cache_key "$scheme://$host$request_uri$do_not_cache";<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_cache staticfilecache;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>add_header Cache-Control public;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_cache_valid<span>       </span>200 120d;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_hide_header "Set-Cookie";<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_ignore_headers<span> 
</span>"Set-Cookie";<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_ignore_headers<span> 
</span>"Cache-Control";<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_hide_header "Cache-Control";<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_pass_header X-Accel-Expires;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span> </span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_set_header Accept-Encoding "";<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_ignore_headers Expires;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>   </span><span>             </span>add_header X-Cache-Status
$upstream_cache_status;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_cache_use_stale<span>   </span>timeout;<span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span>               
</span>proxy_cache_bypass $arg_nocache $do_not_cache;<br clear="all"></p><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div class="gmail_signature" data-smartmail="gmail_signature">- Quintin</div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr">On Sat, May 12, 2018 at 10:29 AM Lucas Rolff <<a href="mailto:lucas@lucasrolff.com">lucas@lucasrolff.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="DA" link="#0563C1" vlink="#954F72">
<div class="m_5039261820505189399WordSection1">
<p class="MsoNormal"><span lang="EN-GB">It can be as simple as doing a curl to your “origin” url (the one you proxy_pass to) for the files you see that gets a lot of MISS’s – if there’s odd headers such as cookies etc, then you’ll most likely experience a bad
 cache if your nginx is configured to not ignore those headers.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:36.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">nginx <<a href="mailto:nginx-bounces@nginx.org" target="_blank">nginx-bounces@nginx.org</a>> on behalf of Quintin Par <<a href="mailto:quintinpar@gmail.com" target="_blank">quintinpar@gmail.com</a>><br>
<b>Reply-To: </b>"<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a>" <<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a>><br>
<b>Date: </b>Saturday, 12 May 2018 at 18.26<br>
<b>To: </b>"<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a>" <<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a>><br>
<b>Subject: </b>Debugging Nginx Cache Misses: Hitting high number of MISS despite high proxy valid<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><a name="m_5039261820505189399__MailOriginalBody"><img id="m_5039261820505189399_x0000_i1025" src="https://mailtrack.io/trace/mail/86a613eb1ce46a4e7fa6f9eb96989cddae639800.png?u=74734" alt="https://mailtrack.io/trace/mail/86a613eb1ce46a4e7fa6f9eb96989cddae639800.png?u=74734"><u></u><u></u></a></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">My proxy cache path is set to a very high size</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">proxy_cache_path  /var/lib/nginx/cache  levels=1:2   keys_zone=staticfilecache:180m  max_size=700m;</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">and the size used is only</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">sudo du -sh *</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">14M cache</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">4.0K    proxy</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">Proxy cache valid is set to</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">proxy_cache_valid 200 120d;</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">I track HIT and MISS via</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">add_header X-Cache-Status $upstream_cache_status;</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">Despite these settings I am seeing a lot of MISSes. And this is for pages I intentionally ran a cache warmer
 an hour ago.</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black">How do I debug why these MISSes are happening? How do I find out if the miss was due to eviction, expiration,
 some rogue header etc? Does Nginx provide commands for this?</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span><span style="font-family:"Arial",sans-serif;color:black"><u></u> <u></u></span></span></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span>- Quintin</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>

_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a></blockquote></div>