<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Feb 25, 2013 at 5:08 PM, Jeffrey Taylor <span dir="ltr"><<a href="mailto:jefe78@gmail.com" target="_blank">jefe78@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>We're using Amazon Cloudfront(CF). The issue we've run into is that when CF gets a 404, it caches that for ~5 minutes. What we want to do is have Varnish(already part of our stack) pass a 200 to CF on a 404 event, but only cache that '404' for ~1 minute. In doing so, we give ourselves 1 minute to recover from the 404 event on our stack, in doing so, we can keep serving content 1 minute after, instead of 5 minutes because of CF.</div>
</div></blockquote><div><br></div>On vcl_fetch, you can test if the response status from backend request is 404 and return a 200 to the client (CloudFrond) using the vcl_error, like this:<div><br></div><div>sub vcl_fetch {</div>
<div>  if (beresp.status == 404) {</div><div>    set beresp.ttl = 1m;</div><div>    error 200 "Not Found";</div><div>  }</div><div><br></div><div>  [...]</div><div>}</div><div><br></div><div>The default vcl_error should return the correct HTTP status code.</div>
<div><br></div><div>But IMHO this isn't a good thing to do with every content from the backend :-) Isn't there a cache TTL setting on CloudFront?</div><div><br></div><div>[]'s</div><div>Hugo</div><div class="gmail_extra">
<a href="http://www.devin.com.br">www.devin.com.br</a><br></div></div></div></div>