BAEL-614 endpoint that has default cache-control headers
This commit is contained in:
parent
3fa1b93f87
commit
4bac6e0571
|
@ -32,4 +32,10 @@ public class ResourceEndpoint {
|
||||||
.cacheControl(CacheControl.noCache())
|
.cacheControl(CacheControl.noCache())
|
||||||
.body(new TimestampDto(LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli()));
|
.body(new TimestampDto(LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/private/users/{name}", method = RequestMethod.GET)
|
||||||
|
public ResponseEntity<UserDto> getUserNotCached(@PathVariable("name") String name) {
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.body(new UserDto(name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
package com.baeldung.cachecontrol.config;
|
|
||||||
|
|
||||||
import org.springframework.http.CacheControl;
|
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@EnableWebMvc
|
|
||||||
public class WebConfiguration extends WebMvcConfigurerAdapter {
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
||||||
registry
|
|
||||||
.addResourceHandler("/resources/**")
|
|
||||||
.addResourceLocations("/resources/")
|
|
||||||
.setCacheControl(CacheControl.maxAge(24, TimeUnit.HOURS));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue