File tree Expand file tree Collapse file tree
spring-security-cache-control/src
main/java/com/baeldung/cachecontrol
test/java/com/baeldung/cachecontrol Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ public ResponseEntity<UserDto> getUser(@PathVariable(value = "name") String name
2929 public ResponseEntity <TimestampDto > getServerTimestamp () {
3030 return ResponseEntity .ok ()
3131 .cacheControl (CacheControl .noStore ())
32- .cacheControl (CacheControl .noCache ())
3332 .body (new TimestampDto (LocalDateTime .now ().toInstant (ZoneOffset .UTC ).toEpochMilli ()));
3433 }
3534
Original file line number Diff line number Diff line change 1414public class ResourceEndpointTest {
1515 private static final String URL_PREFIX = "http://localhost:8080" ;
1616
17- @ Test
18- public void givenServiceEndpoint_whenGetRequestForUser_shouldResponseWithCacheControlMaxAge () {
19- given ()
20- .when ()
21- .get (URL_PREFIX + "/users/Michael" )
22- .then ()
23- .contentType (ContentType .JSON ).and ().statusCode (200 ).and ()
24- .header ("Cache-Control" , "max-age=60" );
25- }
17+ @ Test
18+ public void givenServiceEndpoint_whenGetRequestForUser_shouldResponseWithCacheControlMaxAge () {
19+ given ()
20+ .when ()
21+ .get (URL_PREFIX + "/users/Michael" )
22+ .then ()
23+ .contentType (ContentType .JSON ).and ().statusCode (200 ).and ()
24+ .header ("Cache-Control" , "max-age=60" );
25+ }
2626
2727 @ Test
2828 public void givenServiceEndpoint_whenGetRequestForNotCacheableContent_shouldResponseWithCacheControlNoCache () {
@@ -31,7 +31,7 @@ public void givenServiceEndpoint_whenGetRequestForNotCacheableContent_shouldResp
3131 .get (URL_PREFIX + "/timestamp" )
3232 .then ()
3333 .contentType (ContentType .JSON ).and ().statusCode (200 ).and ()
34- .header ("Cache-Control" , "no-cache " );
34+ .header ("Cache-Control" , "no-store " );
3535 }
3636
3737 @ Test
You can’t perform that action at this time.
0 commit comments