You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Martin Grigorov <mg...@apache.org> on 2013/03/14 10:43:57 UTC

Caching of resources in META-INF/resources folder

Hi,

I'm experiencing troubles with updating CSS/JS resources in
META-INF/resources during development.
My application is a multi module Maven project. Some of the 'jar' modules
(i.e. the ones that are packed in WEB-INF/lib/**) have META-INF/resources
with some CSS/JS files inside.

Deploying the project in Tomcat 7.0.37 in the IDE (Intellij IDEA) as
"exploded-war" allows me to edit my .java files and the resources which end
in the context root (in Maven terminology - src/main/webapp) then do
"update classes and resources" in the IDE and I can see my changes in the
browser.

Unfortunately this doesn't work for META-INF/resources (Servlet 3.0)
because it seems Tomcat very aggressively caches these resources.
I've stepped with the debugger thru various **DirContext implementations
and I see that the lastModificationTime is cached in JNDI Attributes and
the file content itself
in org.apache.naming.resources.Resource#binaryContent.

Am I correct to assume that there is no way to archive the short
development cycle with META-INF/resources ?

Thanks
Martin

Re: Caching of resources in META-INF/resources folder

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Mar 14, 2013 at 10:43 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> I'm experiencing troubles with updating CSS/JS resources in
> META-INF/resources during development.
> My application is a multi module Maven project. Some of the 'jar' modules
> (i.e. the ones that are packed in WEB-INF/lib/**) have META-INF/resources
> with some CSS/JS files inside.
>
> Deploying the project in Tomcat 7.0.37 in the IDE (Intellij IDEA) as
> "exploded-war" allows me to edit my .java files and the resources which end
> in the context root (in Maven terminology - src/main/webapp) then do
> "update classes and resources" in the IDE and I can see my changes in the
> browser.
>
> Unfortunately this doesn't work for META-INF/resources (Servlet 3.0)
> because it seems Tomcat very aggressively caches these resources.
> I've stepped with the debugger thru various **DirContext implementations
> and I see that the lastModificationTime is cached in JNDI Attributes and
> the file content itself
> in org.apache.naming.resources.Resource#binaryContent.
>
> Am I correct to assume that there is no way to archive the short
> development cycle with META-INF/resources ?
>
> Thanks
> Martin
>

I just realized that the IDE does the update of the resources and a quick
search led me to http://youtrack.jetbrains.com/issue/IDEA-72577
I'm not sure how they do this for the resources in the context root but I
guess they use some Tomcat internal APIs, or reflection to clean the caches.
If you think you know how this may be improved please comment in this
ticket.

Thank you!

-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>