A simple Spring Boot starter that provides the @HttpCache annotation to easily add HTTP cache headers to your REST controller responses.
Add the dependency to your
pom.xml:<dependency> <groupId>com.jeevision.spring.http</groupId> <artifactId>cache-control</artifactId> <version>1.0.2</version> </dependency>
Annotate your REST controller methods:
@RestControllerpublicclassMyController { @HttpCache@GetMapping("/api/data") publicStringgetData() { return"ok"; } }
The response will automatically include
Cache-Control: public, max-age=300header.
cachePublic(boolean, default: true) - Sets "public" or "private" in Cache-ControlmaxAgeSeconds(int, default: 300) - Sets the max-age value in seconds