title: Apache Velocity disable template & resource caching
body: <p>I have a Spring Boot application that exposes an API for rendering a relatively simple velocity template. The template uses <code>#parse</code> to include a couple of other templates, and otherwise writes out some basic variables passed to it from the Java layer. The templates are inside the JAR file, so they're loaded from the classpath. I use the following velocity engine setup that's created on-the-fly per-request:</p>
  
  <pre><code>    VelocityEngine ve = new VelocityEngine();
      ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
      ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
      ve.setProperty("classpath.resource.loader.cache", "false");
      ve.setProperty("velocity.engine.resource.manager.cache.enabled", "false");
      ve.setProperty("resource.manager.cache.enabled", "false");
      ve.init();
  </code></pre>
  
  <p>Multiple parts of the template are meant to be unique per-request (the resource is used as the response to a simple Spring MVC controller), so I need to disable caching of the template resources. I have tried the above configuration as-is, as well as defining it in a <code>velocity.properties</code> file that's in <code>src/main/resources</code>, but changing the template or the files does not "take effect" until I restart the application.</p>
  
  <p>Doing what <a href="http://velocity.apache.org/engine/devel/developer-guide.html#pluggable-resource-manager-and-resource-cache" rel="nofollow">this documentation</a> page says doesn't seem to help (indeed you can see what it does above).</p>
  
  <p>The engine code above is inside a Spring <code>Component</code> class and even when moving the <code>VelocityEngine</code> stuff to a static final field and just initialising the velocity context each time has not helped. </p>
  
  <p>How can force Spring/Velocity to load templates &amp; included resources each time?</p>