You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Hoying, Ken" <Ke...@PremierInc.com> on 2010/02/15 20:33:55 UTC
[Q] Enable Freemarker template caching
I am finding the text regarding the enablement of Freemarker template caching in the performance tuning document (http://struts.apache.org/2.1.8.1/docs/performance-tuning.html) to be a bit confusing.
The document states:
<start clip>
As of Struts 2.0.10, setting the property struts.freemarker.templatesCache to true will enable the Struts internal caching of Freemarker templates. This property is set to false by default.
In Struts versions prior to 2.0.10, you had to copy the /template directory from the Struts 2 jar in your WEB_APP root to utilize Freemarker's built in chaching mechanism in order to achieve similar results.
The built in Freemarker caching mechanism fails to properly cache templates when they are retrieved from the classpath. Copying them to the WEB_APP root allows Freemarker to cache them correctly. Freemarker looks at the last modified time of the template to determine if it needs to reload the templates. Resources retrieved from the classpath have no last modified time, so Freemarker will reload them on every request.
<end clip>
I am confused. Do I or don't I need to copy the Freemarker templates to my WEBAPP to take advantage of the caching? Do I copy them to WEBAPP\template\.. or to WEBAPP\struts\template like with the static content?
Thanks,
Ken
-----------------------------------------
***Note:The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify the Sender
immediately by replying to the message and deleting it from your
computer. Thank you. Premier Inc.
RE: [Q] Enable Freemarker template caching
Posted by "Hoying, Ken" <Ke...@PremierInc.com>.
Not exactly sure what you are attempting, but you can utilize OGNL in struts.xml and in particular within results. Take a look at the following and see if it is any help:
http://struts.apache.org/2.1.8.1/docs/parameters-in-configuration-results.html
-----Original Message-----
From: Oscar [mailto:oscar.kalderon@gmail.com]
Sent: Monday, February 15, 2010 11:53 PM
To: Struts Users Mailing List
Subject: Re: [Q] Enable Freemarker template caching
Hi to all, i have a doubt about struts 2. Is possible to write ognl
expressions on struts.xml . Let's say, something like wildcards but instead
wildcards build the value of result with some attribute from request or a
value of session, that's possible?
THanks in regard
--
Oscar
-----------------------------------------
***Note:The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify the Sender
immediately by replying to the message and deleting it from your
computer. Thank you. Premier Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Q] Enable Freemarker template caching
Posted by Oscar <os...@gmail.com>.
Hi to all, i have a doubt about struts 2. Is possible to write ognl
expressions on struts.xml . Let's say, something like wildcards but instead
wildcards build the value of result with some attribute from request or a
value of session, that's possible?
THanks in regard
--
Oscar
Re: [Q] Enable Freemarker template caching
Posted by Wes Wannemacher <we...@wantii.com>.
If you are using struts 2.0.9 or earlier, then you will have to copy
the template directory out of the struts2-core jar file into your
web-app. (Off the top of my head, I can't remember if you copy it to
context-root, context-root/WEB-INF, context-root/WEB-INF/classes, but
I'm sure that's in the docs or online somewhere).
If you are using 2.0.10 or higher, then just set the mentioned value
to true... You can do that by putting this in your struts.xml file -
<constant name="struts.freemarker.templatesCache" value="true" />
-Wes
On Mon, Feb 15, 2010 at 2:33 PM, Hoying, Ken <Ke...@premierinc.com> wrote:
> I am finding the text regarding the enablement of Freemarker template caching in the performance tuning document (http://struts.apache.org/2.1.8.1/docs/performance-tuning.html) to be a bit confusing.
>
> The document states:
> <start clip>
> As of Struts 2.0.10, setting the property struts.freemarker.templatesCache to true will enable the Struts internal caching of Freemarker templates. This property is set to false by default.
>
> In Struts versions prior to 2.0.10, you had to copy the /template directory from the Struts 2 jar in your WEB_APP root to utilize Freemarker's built in chaching mechanism in order to achieve similar results.
>
> The built in Freemarker caching mechanism fails to properly cache templates when they are retrieved from the classpath. Copying them to the WEB_APP root allows Freemarker to cache them correctly. Freemarker looks at the last modified time of the template to determine if it needs to reload the templates. Resources retrieved from the classpath have no last modified time, so Freemarker will reload them on every request.
> <end clip>
>
> I am confused. Do I or don't I need to copy the Freemarker templates to my WEBAPP to take advantage of the caching? Do I copy them to WEBAPP\template\.. or to WEBAPP\struts\template like with the static content?
>
> Thanks,
> Ken
>
>
>
> -----------------------------------------
> ***Note:The information contained in this message may be privileged
> and confidential and protected from disclosure. If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient,
> you are hereby notified that any dissemination, distribution or
> copying of this communication is strictly prohibited. If you have
> received this communication in error, please notify the Sender
> immediately by replying to the message and deleting it from your
> computer. Thank you. Premier Inc.
--
Wes Wannemacher
Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Q] Enable Freemarker template caching
Posted by Dale Newfield <da...@newfield.org>.
Hoying, Ken wrote:
> In Struts versions prior to 2.0.10, you had to copy the /template
> directory from the Struts 2 jar in your WEB_APP root to utilize
> Freemarker's built in chaching mechanism in order to achieve similar
> results.
And I think as a result of following this old advice I've now got older
revisions of many of these files in my app than I would otherwise, which
should probably be listed here as a caveat should this still be the
correct advice.
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org