Proxy Cache 502 Problem

We´re trying to cache all of our JS files using Proxy Cache from
HttpProxyModule but somehow we always get confused responses from the
server, sometimes we get a 502 error and sometimes we get the cached JS
files… heres the config:

proxy_temp_path /tmp/proxy/proxy_temp_path;
proxy_cache_path /tmp/proxy/proxy_cache_path levels=1:2
keys_zone=cache_one:10m inactive=1d max_size=5m;

 location ~ .*\.(js)$
 {
   proxy_cache cache_one;
   proxy_pass          http://localhost:8080;
         proxy_cache_valid       200  1h;
         proxy_cache_use_stale   error timeout invalid_header;
 }

Anyone who can help out?

Posted at Nginx Forum:

Nobody there who can help out? What am I actually doing wrong? Proxy
Cache is activated on the application servers behind of the nginx load
balancers, but the results are really unstable…

Posted at Nginx Forum: