I have worked out the problem with ESRI support. It's a problem with the web map adapter for 10.2.1. For some reason, the web map adapter messes up the tiled caches in secured folders using tokens. This only happens in the flex viewer.To get around this problem, I just made a proxy server and got rid of the tokens. This solved the issue.