I have a servlet to offer images resources via spring:
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/thumbnails", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> getThumbnail(int id) {
return service.find(id);
}
Resulting http headers: Cache-control: "max-age=0".
Question: how can I control the cache header just for that method?
I guess you can implement the check of the last modified, Spring has support for that - ref API
Something like
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/thumbnails", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> getThumbnail(int id) {
youeObject = service.find(id);
ResponseBuilder builder = Response.ok(youeObject);
builder.cacheControl(CacheControl.maxAge(24, TimeUnit.HOURS)).cachePrivate());
return builder.build();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With