diff options
author | 杨宇千 <crupest@outlook.com> | 2019-08-29 00:03:48 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-08-29 00:03:48 +0800 |
commit | ee73f13b903e953f9bbb730514bf1faa1204e1d0 (patch) | |
tree | d7a8655e999fe3143e5a5436a6d157c7bcc93e88 /Timeline | |
parent | 0bbc5766119d9241473c737b5626e6b455ebba2b (diff) | |
download | timeline-ee73f13b903e953f9bbb730514bf1faa1204e1d0.tar.gz timeline-ee73f13b903e953f9bbb730514bf1faa1204e1d0.tar.bz2 timeline-ee73f13b903e953f9bbb730514bf1faa1204e1d0.zip |
Use cache attribute.
Diffstat (limited to 'Timeline')
-rw-r--r-- | Timeline/Controllers/UserAvatarController.cs | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/Timeline/Controllers/UserAvatarController.cs b/Timeline/Controllers/UserAvatarController.cs index 96b43bdb..e7e12d0b 100644 --- a/Timeline/Controllers/UserAvatarController.cs +++ b/Timeline/Controllers/UserAvatarController.cs @@ -61,11 +61,10 @@ namespace Timeline.Controllers [HttpGet("users/{username}/avatar")]
[Authorize]
+ [ResponseCache(NoStore = false, Location = ResponseCacheLocation.None, Duration = 0)]
public async Task<IActionResult> Get([FromRoute] string username)
{
const string IfNonMatchHeaderKey = "If-None-Match";
- const string CacheControlHeaderKey = "Cache-Control";
- const string CacheControlHeaderValue = "no-cache, must-revalidate, max-age=1";
try
{
@@ -79,7 +78,6 @@ namespace Timeline.Controllers if (eTagList.FirstOrDefault(e => e.Equals(eTag)) != null)
{
- Response.Headers.Add(CacheControlHeaderKey, CacheControlHeaderValue);
Response.Headers.Add("ETag", eTagValue);
return StatusCode(StatusCodes.Status304NotModified);
}
@@ -88,7 +86,6 @@ namespace Timeline.Controllers var avatarInfo = await _service.GetAvatar(username);
var avatar = avatarInfo.Avatar;
- Response.Headers.Add(CacheControlHeaderKey, CacheControlHeaderValue);
return File(avatar.Data, avatar.Type, new DateTimeOffset(avatarInfo.LastModified), eTag);
}
catch (UserNotExistException e)
|