Tomcat 9 Slow Response Times When Serving Large JSP Pages with Caching Enabled
I've been working on this all day and I'm prototyping a solution and I've been working on this all day and I've looked through the documentation and I'm still confused about I'm experiencing significantly slow response times when accessing large JSP pages on Tomcat 9, even with caching enabled... The application uses Spring MVC and I have configured caching in my `web.xml` file as follows: ```xml <servlet> <servlet-name>jsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> <init-param> <param-name>modificationTestInterval</param-name> <param-value>0</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> ``` I've also set up caching headers in my Spring configuration: ```java import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @EnableWebMvc public class WebConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/resources/**") .addResourceLocations("classpath:/static/") .setCachePeriod(3600); } } ``` Despite these configurations, the first request to any large JSP page takes an excessive time to load (around 5-10 seconds), while subsequent requests are much faster. I've looked into the Tomcat logs and noticed the following warning: ``` WARNING [http-nio-8080-exec-1] org.apache.jasper.servlet.JspServlet - JSP file '/WEB-INF/views/largePage.jsp' has been modified; reloading page. ``` This indicates that the JSPs are being recompiled on the first request, which I suspect is causing the delay. I even tried changing `modificationTestInterval` to `-1` to disable the checks, but it doesn't seem to help. My questions are: - How can I prevent Tomcat from recompiling the JSP pages every time I access them? - Are there any best practices I should follow for optimizing the performance of large JSP pages in Tomcat? Any insights or recommendations would be greatly appreciated! This issue appeared after updating to Java 3.10. I'd really appreciate any guidance on this. The stack includes Java and several other technologies. Am I approaching this the right way?