Skip to content

Allow the TTL of Tomcat's resource cache to be configured via the environment #9670

@bohrqiu

Description

@bohrqiu

All http request served by tomcat will validateResource,when StandardRoot has too many resouces(org.apache.catalina.webresources.StandardRoot#allResources),the performance is slow. spring-boot 1.5.1 has the problem,allResources contains all classpath library. thanks committers ,this have been fixed at spring-boot 1.5.4.

wechatimg33

but when app run in fatjar or war,resource can't be change anymore,tomcat org.apache.catalina.webresources.Cache#ttl is too short(default is 5 second).

in my case ,i had set the cache as follows:

 ((TomcatEmbeddedServletContainerFactory)factory).addContextLifecycleListeners(
          event -> {
            if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
              ((StandardContext) event.getLifecycle())
                  .getResources()
                  .setCacheTtl(100l * 24 * 60 * 60 * 1000);//set cache ttl 100 days
            }
          });

can there be have some default strategy for this?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions