You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Jochen Toppe <jo...@jtoee.com> on 2004/10/24 15:26:34 UTC

RE: Template Caching

I have one veloc engine in my app and have my own resource loader coupled
with the underlying cms's publication mechanism. Invalidation and
reloading of the templates works like a charm. Even w/ the file resource
loader which I also use. Ya must be doing something wrong. Download the
source, hook up a debugger and you'll probably figure it out in 10
minutes. Software is just human, not a mystery :) To avoid browser cache,
CRTL-reload or shift-reload (depending on the browser) will also do the
trick.

Cheers,
  jochen

> Hi,
>
>
> In my application, I used Velocity engine as a separate instance each
> time for evaluating templates, basically non-singlton. I find the
> performance is not that bad.
>
> What I did is that, I created a class called VelocityParser and have it
> encapsulate the VelocityEngine class. Each time I want to render a
> template, I used new VelocityParser().render(...), which in turn, new up a
> VelocityEngine
> object and does the real rendering.
>
> This way, there is no template caching issue. You can even turn on
> template caching and make a singlton class afterwards by doing:
> VelocityParser.newInstance().render(...).
>
>
> Cheers,
>
>
> Jian
>
>
>> ===== Original Message From "Steve O'Hara"
>> <so...@pivotal-solutions.co.uk>
>>
> =====
>
>> Hi Shinobu,
>>
>>
>> Yeh, it's a mystery..........
>> To check that it definitely wasn't the browser cache, I set an expires
>> header and no-cache control. Also, I switched from IE to Mozilla whilst
>> Tomcat was running and it still
>> showed the cached page. It does show any changed context data, which
>> would also indicate that it isn't a browser issue.
>>
>> I suppose I'm getting to the poitn where I'll need to download the
>> Velocity
>> source and debug it.......?
>>
>> Steve
>>
>>
>>
>> -----Original Message-----
>> From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com]
>> Sent: 23 October 2004 17:38
>> To: Velocity Users List
>> Subject: Re: Template Cacheing
>>
>>
>>
>> Hi Steve,
>>
>>
>>> Thanks for your notes, but I still can't turn the cacheing off.
>>>
>>>
>>> This is my code............
>>>
>>
>> ## snip
>>
>>
>>> What am I doing wrong ?
>>>
>> Hmm.  AFAICS, nothing.  Actually your code worked in my environment.
>> (I use Tomcat 5.5, but that shouldn't matter.)  Even more,
>> FileResourceLoader doesn't cache by default.  Could it be that your
>> browser is caching, and not Velocity?
>>
>> Best regards,
>> -- Shinobu Kawai
>>
>>
>> --
>> Shinobu Kawai <sh...@gmail.com>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


RE: Template Caching

Posted by Jochen Toppe <jo...@jtoee.com>.
I'ne never trusted those IDE-deploy functions. I use Idea (and love it)
myself but use Ant to deploy everything into a container, jpda to debug.
That has the advantage that you can use the same scripts for nightly
builds, building RPMs/sun packages/... And no magic that I don't build
myself :)

cu,
  j.

>

> I've figured out what's going on........
> I'm using IDEA coupled to Tomcat for my debugging. IDEA creates a
> deployment directory (exploded) each time you run a debug session, copies
> all your files (inlcuding the templates) into this directory, installs the
> servlet as an app in Tomcat and runs. Hence, any changes to my source
> templates are not being seen by Velocity because I'm running in a
> different directory tree.
>
> Thanks for all your help.
>
>
> Steve
>
>
>
> -----Original Message-----
> From: Jochen Toppe [mailto:jochen@jtoee.com]
> Sent: 24 October 2004 14:27
> To: Velocity Users List
> Cc: Steve O'Hara; Shinobu Kawai; Velocity Users List
> Subject: RE: Template Caching
>
>
>
>
> I have one veloc engine in my app and have my own resource loader coupled
>  with the underlying cms's publication mechanism. Invalidation and
> reloading of the templates works like a charm. Even w/ the file resource
> loader which I also use. Ya must be doing something wrong. Download the
> source, hook up a debugger and you'll probably figure it out in 10
> minutes. Software is just human, not a mystery :) To avoid browser cache,
>  CRTL-reload or shift-reload (depending on the browser) will also do the
> trick.
>
> Cheers,
> jochen
>
>> Hi,
>>
>>
>>
>> In my application, I used Velocity engine as a separate instance each
>> time for evaluating templates, basically non-singlton. I find the
>> performance is not that bad.
>>
>> What I did is that, I created a class called VelocityParser and have it
>>  encapsulate the VelocityEngine class. Each time I want to render a
>> template, I used new VelocityParser().render(...), which in turn, new
>> up a VelocityEngine
>> object and does the real rendering.
>>
>> This way, there is no template caching issue. You can even turn on
>> template caching and make a singlton class afterwards by doing:
>> VelocityParser.newInstance().render(...).
>>
>>
>>
>> Cheers,
>>
>>
>>
>> Jian
>>
>>
>>
>>> ===== Original Message From "Steve O'Hara"
>>> <so...@pivotal-solutions.co.uk>
>>>
>>>
>> =====
>>
>>
>>> Hi Shinobu,
>>>
>>>
>>>
>>> Yeh, it's a mystery..........
>>> To check that it definitely wasn't the browser cache, I set an expires
>>>  header and no-cache control. Also, I switched from IE to Mozilla
>>> whilst Tomcat was running and it still
>>> showed the cached page. It does show any changed context data, which
>>> would also indicate that it isn't a browser issue.
>>>
>>> I suppose I'm getting to the poitn where I'll need to download the
>>> Velocity
>>> source and debug it.......?
>>>
>>> Steve
>>>
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com]
>>> Sent: 23 October 2004 17:38
>>> To: Velocity Users List
>>> Subject: Re: Template Cacheing
>>>
>>>
>>>
>>>
>>> Hi Steve,
>>>
>>>
>>>
>>>> Thanks for your notes, but I still can't turn the cacheing off.
>>>>
>>>>
>>>>
>>>> This is my code............
>>>>
>>>>
>>>
>>> ## snip
>>>
>>>
>>>
>>>> What am I doing wrong ?
>>>>
>>>>
>>> Hmm.  AFAICS, nothing.  Actually your code worked in my environment.
>>> (I use Tomcat 5.5, but that shouldn't matter.)  Even more,
>>> FileResourceLoader doesn't cache by default.  Could it be that your
>>> browser is caching, and not Velocity?
>>>
>>> Best regards,
>>> -- Shinobu Kawai
>>>
>>>
>>>
>>> --
>>> Shinobu Kawai <sh...@gmail.com>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>>  To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>  For additional commands, e-mail:
>>> velocity-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>>  To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>  For additional commands, e-mail:
>>> velocity-user-help@jakarta.apache.org
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Template Caching - IDEA

Posted by "Marino A. Jonsson" <ma...@hotmail.com>.
if you think Tomcat startup is sloooow you might consider taking Jetty for a
spin - it's simply adorable :-)

cheers,
Marin�


"Tim Colson" <tc...@cisco.com> wrote in message
news:200410251534.IAA16722@malone.cisco.com...
> > I've figured out what's going on........
> > I'm using IDEA coupled to Tomcat for my debugging. IDEA
> > creates a deployment
> > directory (exploded) each time you run a debug session,
> Doh. I've run into that too -- in 4.5.1 the exploded dir was required, but
I
> could hit "make" and it just copied the changed template files. In 4.5.2
> however, IDEA seems to also restart Tomcat which is sloooow.
>
> I found that in 4.5.2, you can specify not to create an exploded
directory,
> and use and existing directory instead. So for Velocity integration to
work
> nicely, I have a directory <project>/webapp which has the standard servlet
> dirs (e.g. /WEB-INF) and point the web module config at the web.xml file
at
> /webapp/WEB-INF/web.xml. This means you can edit Velocity templates inside
> IDEA, and see the changes immediately.
>
> Aside -- another benefit of this structure -- with a couple ant tasks, the
> app can be given to an HTML Designer via CVS. After setting up Java &
Tomcat
> on their machine, they can launch the webapp, edit templates, refresh
> browser to see them, and commit changes to CVS. Works great. :-)
>
> Timo




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


RE: Template Caching - IDEA

Posted by Tim Colson <tc...@cisco.com>.
> I've figured out what's going on........
> I'm using IDEA coupled to Tomcat for my debugging. IDEA 
> creates a deployment
> directory (exploded) each time you run a debug session, 
Doh. I've run into that too -- in 4.5.1 the exploded dir was required, but I
could hit "make" and it just copied the changed template files. In 4.5.2
however, IDEA seems to also restart Tomcat which is sloooow.

I found that in 4.5.2, you can specify not to create an exploded directory,
and use and existing directory instead. So for Velocity integration to work
nicely, I have a directory <project>/webapp which has the standard servlet
dirs (e.g. /WEB-INF) and point the web module config at the web.xml file at
/webapp/WEB-INF/web.xml. This means you can edit Velocity templates inside
IDEA, and see the changes immediately. 

Aside -- another benefit of this structure -- with a couple ant tasks, the
app can be given to an HTML Designer via CVS. After setting up Java & Tomcat
on their machine, they can launch the webapp, edit templates, refresh
browser to see them, and commit changes to CVS. Works great. :-)

Timo


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


RE: Template Caching

Posted by Steve O'Hara <so...@pivotal-solutions.co.uk>.
I've figured out what's going on........
I'm using IDEA coupled to Tomcat for my debugging. IDEA creates a deployment
directory (exploded) each time you run a debug session, copies all your
files (inlcuding the templates) into this directory, installs the servlet as
an app in Tomcat and runs.
Hence, any changes to my source templates are not being seen by Velocity
because I'm running in a different directory tree.

Thanks for all your help.

Steve


-----Original Message-----
From: Jochen Toppe [mailto:jochen@jtoee.com]
Sent: 24 October 2004 14:27
To: Velocity Users List
Cc: Steve O'Hara; Shinobu Kawai; Velocity Users List
Subject: RE: Template Caching



I have one veloc engine in my app and have my own resource loader coupled
with the underlying cms's publication mechanism. Invalidation and
reloading of the templates works like a charm. Even w/ the file resource
loader which I also use. Ya must be doing something wrong. Download the
source, hook up a debugger and you'll probably figure it out in 10
minutes. Software is just human, not a mystery :) To avoid browser cache,
CRTL-reload or shift-reload (depending on the browser) will also do the
trick.

Cheers,
  jochen

> Hi,
>
>
> In my application, I used Velocity engine as a separate instance each
> time for evaluating templates, basically non-singlton. I find the
> performance is not that bad.
>
> What I did is that, I created a class called VelocityParser and have it
> encapsulate the VelocityEngine class. Each time I want to render a
> template, I used new VelocityParser().render(...), which in turn, new up a
> VelocityEngine
> object and does the real rendering.
>
> This way, there is no template caching issue. You can even turn on
> template caching and make a singlton class afterwards by doing:
> VelocityParser.newInstance().render(...).
>
>
> Cheers,
>
>
> Jian
>
>
>> ===== Original Message From "Steve O'Hara"
>> <so...@pivotal-solutions.co.uk>
>>
> =====
>
>> Hi Shinobu,
>>
>>
>> Yeh, it's a mystery..........
>> To check that it definitely wasn't the browser cache, I set an expires
>> header and no-cache control. Also, I switched from IE to Mozilla whilst
>> Tomcat was running and it still
>> showed the cached page. It does show any changed context data, which
>> would also indicate that it isn't a browser issue.
>>
>> I suppose I'm getting to the poitn where I'll need to download the
>> Velocity
>> source and debug it.......?
>>
>> Steve
>>
>>
>>
>> -----Original Message-----
>> From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com]
>> Sent: 23 October 2004 17:38
>> To: Velocity Users List
>> Subject: Re: Template Cacheing
>>
>>
>>
>> Hi Steve,
>>
>>
>>> Thanks for your notes, but I still can't turn the cacheing off.
>>>
>>>
>>> This is my code............
>>>
>>
>> ## snip
>>
>>
>>> What am I doing wrong ?
>>>
>> Hmm.  AFAICS, nothing.  Actually your code worked in my environment.
>> (I use Tomcat 5.5, but that shouldn't matter.)  Even more,
>> FileResourceLoader doesn't cache by default.  Could it be that your
>> browser is caching, and not Velocity?
>>
>> Best regards,
>> -- Shinobu Kawai
>>
>>
>> --
>> Shinobu Kawai <sh...@gmail.com>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org