You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Nathan Rogers <nr...@library.wisc.edu> on 2003/09/15 21:49:56 UTC

Template caching within a Struts based servlet

I'm using Velocity as the view component of several Struts based 
servlets.  It works fine except that it seems to chew through heaps of 
memory.  How do I see if caching is enabled, and if not, turn it on? 
I've included the ResourceLoader settings from my velocity.properties 
file below.  I see some stuff about setting a flag to true but I don't 
see that flag in the file.

#----------------------------------------------------------------------------
# RESOURCE MANAGEMENT
#----------------------------------------------------------------------------
# Allows alternative ResourceManager and ResourceCache implementations
# to be plugged in.
#----------------------------------------------------------------------------
resource.manager.class = 
org.apache.velocity.runtime.resource.ResourceManagerImpl
resource.manager.cache.class = 
org.apache.velocity.runtime.resource.ResourceCacheImpl

-- 
Nathan Rogers
Library Technology Group
312F Memorial Library
728 State Street
261-1409



Re: Template caching within a Struts based servlet

Posted by Nathan Bubna <na...@esha.com>.
Nathan Rogers said:
> Nathan Bubna wrote:
> > Nathan Rogers said:
...
> > http://jakarta.apache.org/velocity/developer-guide.html
> >
> > --------------------------------------------------
> > Developer's Guide
> >     -Configuration Keys and Values
> >         -Resource Management
> >
> > ...
> > <name>.resource.loader.cache = false
...
> I saw that in the manual but I wasn't sure how it applied to the
> Velocity tools.  It must be using a ResourceLoader but I am unclear as
> to how to tell which was being used - in the default velocity.properties
> packaged with VelocityStruts there isn't a section defined for
> *.resource.loader, just resource.manager.  Are these two the same thing?
> (ie will setting resource.manager.cache = true do the same as setting
> *.resource.loader.cache = true)

there isn't really a "default velocity.properties packaged with
VelocityStruts."  there is a velocity.properties that comes with the example,
but that is by no means definitive.  it's just an example and only sets a
subset of the available configuration keys.  the documentation is far more
authoritative and comprehensive.

that said, the resource manager manages resource loaders.  AFAIU, the manager
depends on the loaders to tell it whether or not to cache a resource.  this
allows you to have multiple resource loaders where some resources are cached
and some are (not.  of course, most people will use just one resource loader).

afaik, setting "resource.manager.cache = true" will do nothing.  there is no
such configuration key.  personally, i'd recommend sticking to the documented
keys and not making a habit of second guessing them or inventing new ones.  ;)

Nathan Bubna
nathan@esha.com


Re: Template caching within a Struts based servlet

Posted by Nathan Rogers <nr...@library.wisc.edu>.
Nathan Bubna wrote:

> Nathan Rogers said:
> 
>>I'm using Velocity as the view component of several Struts based
>>servlets.  It works fine except that it seems to chew through heaps of
>>memory.  How do I see if caching is enabled, and if not, turn it on?
>>I've included the ResourceLoader settings from my velocity.properties
>>file below.  I see some stuff about setting a flag to true but I don't
>>see that flag in the file.
> 
> 
> RTM :)
> 
> http://jakarta.apache.org/velocity/developer-guide.html
> 
> --------------------------------------------------
> Developer's Guide
>     -Configuration Keys and Values
>         -Resource Management
> 
> ...
> <name>.resource.loader.cache = false
> Controls caching of the templates in the loader. Default is false, to make
> life easy for development and debugging. This should be set to true for
> production deployment. When 'true', the modificationCheckInterval property
> applies. This allows for the efficiency of caching, with the convenience of
> controlled reloads - useful in a hosted or ISP environment where templates can
> be modifed frequently and bouncing the application or servlet engine is not
> desired or permitted.
> ...
> ---------------------------------------------------

I saw that in the manual but I wasn't sure how it applied to the 
Velocity tools.  It must be using a ResourceLoader but I am unclear as 
to how to tell which was being used - in the default velocity.properties 
packaged with VelocityStruts there isn't a section defined for 
*.resource.loader, just resource.manager.  Are these two the same thing? 
(ie will setting resource.manager.cache = true do the same as setting 
*.resource.loader.cache = true)

> Nathan Bubna
> nathan@esha.com

-- 
Nathan Rogers
Library Technology Group
312F Memorial Library
728 State Street
261-1409


Re: Template caching within a Struts based servlet

Posted by Nathan Bubna <na...@esha.com>.
Nathan Rogers said:
> I'm using Velocity as the view component of several Struts based
> servlets.  It works fine except that it seems to chew through heaps of
> memory.  How do I see if caching is enabled, and if not, turn it on?
> I've included the ResourceLoader settings from my velocity.properties
> file below.  I see some stuff about setting a flag to true but I don't
> see that flag in the file.

RTM :)

http://jakarta.apache.org/velocity/developer-guide.html

--------------------------------------------------
Developer's Guide
    -Configuration Keys and Values
        -Resource Management

...
<name>.resource.loader.cache = false
Controls caching of the templates in the loader. Default is false, to make
life easy for development and debugging. This should be set to true for
production deployment. When 'true', the modificationCheckInterval property
applies. This allows for the efficiency of caching, with the convenience of
controlled reloads - useful in a hosted or ISP environment where templates can
be modifed frequently and bouncing the application or servlet engine is not
desired or permitted.
...
---------------------------------------------------

Nathan Bubna
nathan@esha.com