Languages
[Edit]
EN

Spring Boot - setCachePeriod for /static data from application.properties

9 points
Created by:
daniell
280

In this short article, we would like to show how to enable static resources caching by Spring Boot Application using application.properties file.

resources/application.properties file:

...

spring.web.resources.cache.period=P30D

...

Where:

  • P30D means 30 days period.

 

We can set 30 days using seconds:

spring.web.resources.cache.period=2592000

From documentation:

spring.web.resources.cache.period - Cache period for the resources served by the resource handler. If a duration suffix is not specified, seconds will be used.

Can be overridden by the spring.web.resources.cache.cachecontrol properties.

 

References

  1. spring.web.resources.cache.period - Spring Boot Docs 
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join