fix redirect bug + handle cache (fix #8)