Dónal
Dónal

Reputation: 187539

bypass FreeMarker caching?

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.

Upvotes: 3

Views: 3584

Answers (2)

toluju
toluju

Reputation: 4107

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");

Upvotes: 1

Dan Vinton
Dan Vinton

Reputation: 26769

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.

Upvotes: 3

Related Questions