http://wiki.nginx.org/HttpCoreModule#Variables gives amongst others the following:
$sent_http_HEADER
The value of the HTTP response header HEADER when converted to lowercase and
with 'dashes' converted to 'underscores',
e.g. $sent_http_cache_control, $sent_http_content_type...;
$cookie_COOKIE
The value of the cookie COOKIE;
if you combine that with an if block you could do something like:
if ($sent_http_your_added_header = "") {
proxy_cache your_cache_zone;
}
if ($cookie_BYPASS = "1") {
proxy_bypass $cookie_BYPASS;
}
Note: you could actually forget about the if and just use $cookie_BYPASS if your BYPASS cookie has either a 1 or 0 value, see http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_bypass
as far cache times goes, as http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid explains, nginx responds to “X-Accel-Expires”, “Expires” and "Cache-Control” headers
(unless you tell it not to with proxy_ignore_headers directive)