views:

493

answers:

2

Is it possible to bypass the Freemarker cache when certain templates are requested? I realise that I'll probably have to implement my own TemplateLoader in order to do this, but even so, I can't see a way to check the cache when say template A is requested, but bypass it when template B is requested?

If this is not possible, I'll just have to disable caching completely.

+1  A: 

try disabling caching on your configuration:

configuration.setTemplateUpdateDelay(0);

This should cause it to check for a newer version of a template every time it's requested.

To skip the cache for only certain templates, you only need to override getLastModified to return a very old date for certain templates, forcing a reload.

Dan Vinton
A: 

You would set this on the configuration object itself. See this page for details.

For your particular problem, you could do the following:

cfg.setSetting(Configuration.CACHE_STORAGE_KEY, "strong:0, soft:0");
toluju