views:

115

answers:

3

I was under the impression that if I deployed my application (using Ant) then JS files, along with HTML, CSS and images, would be automatically served by Tomcat.

However, after editing Javascript files I have to restart Tomcat in order for the changes to be updated.

My JS files are in a 'js' directory off of root (not in WEB-INF).

I am using FF3.6.

Any help?

+2  A: 

I 've never worked with Tomcat but I find it hard to imagine it wouldn't serve changed JS files straight awayafter deployment. My guess is this is a caching issue on the browser's side. Can you try to force a refresh by opening the actual CSS file and pressing F5?

The usual approach to making sure a JS file gets updated is embedding it with a GET parameter that marks the version/revision:

<script type="text/javascript" src="/js/script.js?version=51"></script>

when you update the script's revision, and change the GET parameter, the browser should forget the cached version and re-load the file.

Pekka
+2  A: 

According to http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

cachingAllowed - If the value of this flag is true, the cache for static resources will be used. If not specified, the default value of the flag is true.

Andrey Yatsyk
A: 

I found out that Tomcat reload files from the /temp directory which was set by setting antiresourcelocking to true in the context xml's. Thanks guys.

Jack