title: $templateCache, ng-template and caching issues - angularjs
body: <p>I am trying to cache my angularjs application's html files, following this suggestion: <a href="https://gist.github.com/ProLoser/6181026" rel="nofollow noreferrer">https://gist.github.com/ProLoser/6181026</a>.</p>
  
  <p>I am appending a dynamic cache key like  <code>?v=123456790</code> to all html files (except those in the templates directory used by angular ui bootstrap).</p>
  
  <p>For partials in their own files, i.e. <code>app/views/customer/customer-history.html</code> this works perfectly. However, for partials in script form, e.g. <code>&lt;script type='text/ng-template' id='customer-history'&gt;</code> the template is not found and a server request is made, resulting in a 404.</p>
  
  <p>E.g. <code>localhost:8080/customer-history/?v=1234567890</code></p>
  
  <p>I can see the templates in question are in the $templateCache. The ones using ng-template are just the name ie <code>customer-history</code> whereas the separate files ones are by path <code>app/views/customer/customer-history.html</code> as you might expect.</p>
  
  <p>It's a large app so going through and moving them all to their own files etc would not be trivial. I've scoured everywhere and I'm not turning anything up so I'm guessing it's something basic with how the templateCache is implemented. </p>
  
  <p>I'm using gulp-templatecache plugin during the build process but the docs are quite limited and I don't think the issue lies there.</p>
  
  <p>My current solution is just to skip the offending templates for now in the function appending the version number by decorating an <code>inCache</code> function onto the $templateCache factory and using it during the check to append the cacheKey. But I feel this is kind of missing the point.</p>