Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

266
Views
Spring Boot or Tomcat cache static assets, have to re-build every time to refresh

Spring Boot or Tomcat caches my static assets .js and .css files in development environment and I have to Build -> Build Project (in IntelliJ) every time to get the refreshed version.

I tried these application properties and they didn't work.

spring.resources.cache-period=0
spring.resources.chain.cache=false
spring.resources.chain.html-application-cache=false
spring.resources.chain.strategy.content.enabled=false
spring.resources.chain.strategy.content.paths=/**

I tried to have this bean to configure Tomcat and it didn't work as well:

@Bean
    public EmbeddedServletContainerFactory servletContainer() {
        TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory() {

            @Override
            protected void postProcessContext(Context context) {
                final int cacheSize = 0;
                StandardRoot standardRoot = new StandardRoot(context);
                standardRoot.setCachingAllowed(false);
                standardRoot.setCacheMaxSize(cacheSize);
                context.setResources(standardRoot);    
            }
        };
        return tomcatFactory;
    }

When changing js and css files I don't want to do Build Project every time, I can even use something like BrowserSync to apply changes automatically to the web page but for that I need Tomcat/Spring to serve static assets in dev environment without me clicking to Build Project.

The doc is not really helpful and according to the doc there is no way except clicking Build every single time changing a css or js file. http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-hotswapping

But I believe this should be something very simple and perfectly achievable isn't it.

Any ideas what should I try next?

Thanks

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This in no cache. Your source files (*.js and *.css) are copied when you build the project in a separate folder (eg target) and from there they are sent to the browser. Build Project button copied this files and then you see that they have changed.

You may enable Build project automatically option in IntelliJ or use other tool (eg bower) for copy files after changing.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!