I. Introduction to TOMCAT "Caching"
Most of the time people like to call the contents of the Tomcat work directory cache, in fact, it is not very appropriate, working directory is only tomcat directory, that is, Tomcat to convert JSP to a class file working directory , which is why it is called the work directory, not the cache directory. Jsp,tomcat works by when a browser accesses a JSP page, Tomcat translates the JSP page into a. java file in the work directory, such as converting index.jsp to a Index_jsp.java file, and then compiling the Index_ Jsp.class file, the last Tomcat container loads the Index_jsp.class class into memory through the ClassLoader class to respond to the client's work.
Tomcat periodically strokes the JSP files in the container, reads the properties of each file, and when a JSP file is found to be changed (the last modification time of the file is not the same as the last stroke), Tomcat will re-convert and compile the JSP file. But Tomcat's stroke is timed and not real-time, which is why JSP files can take a few minutes to change and wait for the modified JSP to take effect. Of course, in order to take effect immediately, many old-timers would recommend clearing the files in the work directory immediately after modifying the JSP page.
In addition, in the Tomcat container, the converted Java files (for example: index_ Jsp.java) Compile maximum support only 64k, so in other containers in the JSP porting to the Tomcat container will encounter a large JSP file can not compile, it is recommended that the business logic in the JSP to write a separate class, in the JSP by invoking the static method of the class to execute, and the JSP page JS extract And put it in a separate JS file.
Second, Tomcat "cache" cleanup
(according to my previous experience, most of the cases will be effective immediately). So here are the three ways to clean up:
Method 1:
Conf/server.xml file
Context path plus reloadable= "true"
Example: <context path= "" docbase= "" reloadable= "true" >
path,docBase,reloadable Attribute Example description: http://ycgit.blog.51cto.com/8590215/1688579
Method 2:
Delete the cache file under the work directory
The Catalina directory can be deleted;
Note: You can not delete the entire directory of work, or restart Tomcat, the conf/web.xml will be deleted, so at startup, the log will prompt: No Default Web. XML, and the access page will display 404 error;
Method 3:
Add the following code to the JSP page, so that the JSP can be loaded in real time, each visit will re- convert the JSP page into a. java file
<meta http-equiv= "Expires" content= "0" >
<meta http-equiv= "Kiben" content= "No-cache" >
Tomcat Cache Cleanup