Optimize view paths caching for plugins.

Closes #2047
Merge pull request #3356 from ADmad/2.5-view-paths

Optimize view paths caching for plugins.