-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #392 from DFE-Digital/response-cache
Allow GET requests to be cached privately for 5m
- Loading branch information
Showing
8 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
GetIntoTeachingApi/Attributes/PrivateShortTermResponseCacheAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace GetIntoTeachingApi.Attributes | ||
{ | ||
public class PrivateShortTermResponseCacheAttribute : ResponseCacheAttribute | ||
{ | ||
public PrivateShortTermResponseCacheAttribute() | ||
{ | ||
Location = ResponseCacheLocation.Client; | ||
Duration = 300; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
GetIntoTeachingApiTests/Attributes/PrivateShortTermResponseCacheAttributeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using FluentAssertions; | ||
using GetIntoTeachingApi.Attributes; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Xunit; | ||
|
||
namespace GetIntoTeachingApiTests.Attributes | ||
{ | ||
public class PrivateShortTermResponseCacheAttributeTests | ||
{ | ||
[Fact] | ||
public void Constructor_CorrectlySetsCacheControl() | ||
{ | ||
var cache = new PrivateShortTermResponseCacheAttribute(); | ||
|
||
cache.Location.Should().Be(ResponseCacheLocation.Client); | ||
cache.Duration.Should().Be(300); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters