duckduckgo/duckduckgo — pull request #92 by jagtalon (2014-08-21 17:05:26+00:00)
Title: Rewrite: Ignore headers if we have proxy_cache_valid set.

We don't want response headers from the endpoints from interfering with proxy_cache_valid. Using proxy_ignore_headers will fix that. We only ignore the headers if we explicitly want to set the caching.

From the [proxy_cache_valid documentation](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid):
> Parameters of caching can also be set directly in the response header. This has higher priority than setting of caching time using the directive. The “X-Accel-Expires” header field sets caching time of a response in seconds. The zero value disables caching for a response. If the value starts with the @ prefix, it sets an absolute time in seconds since Epoch, up to which the response may be cached. If the header does not include the “X-Accel-Expires” field, parameters of caching may be set in the header fields “Expires” or “Cache-Control”. If the header includes the “Set-Cookie” field, such a response will not be cached. Processing of one or more of these response header fields can be disabled using the proxy_ignore_headers directive.

And from the [proxy_ignore_headers documentation](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers):
>"X-Accel-Expires”, “Expires”, “Cache-Control”, and “Set-Cookie” set the parameters of response caching;

Here it is caching things that should be cached (see X-Cache-Status header):
![21](https://cloud.githubusercontent.com/assets/81969/3999615/08c5c434-2952-11e4-8680-96350125cdd8.PNG)

![22](https://cloud.githubusercontent.com/assets/81969/3999920/ff00720c-2954-11e4-8b1d-43ef1dc7bad8.PNG)

Ones that shouldn't be cached still aren't cached like Dictionary/Audio:
![23](https://cloud.githubusercontent.com/assets/81969/3999925/1464e13c-2955-11e4-876b-40c25605c7b5.PNG)