nginx caching per user agent

Why using different cache? Probably it would be sufficient to define your cache key based on $iphone_request variable?

proxy_cache_key "$iphone_request$uri";

Redirect to subdomain for mobile devices (with different caching policy)?