Changed from $request_uri to $uri when writing the file using proxy_store. The reason is that $uri is unescaped and when serving the file from file cache, the url is unsescaped as well so the url "/image%20data/file.jpg" will be written as /image%20data/file.jpg in proxy_store but accessed as /image data/file.jpg when serving the request from file cache.