Improved caching for calls to optimizeResource