-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: RPDE cache headers (#163)"
This reverts commit e73eee3.
- Loading branch information
1 parent
e73eee3
commit 8382e22
Showing
5 changed files
with
12 additions
and
72 deletions.
There are no files selected for viewing
37 changes: 3 additions & 34 deletions
37
Examples/BookingSystem.AspNetCore/Helpers/ResponseContentHelper.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 |
---|---|---|
@@ -1,46 +1,15 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace BookingSystem.AspNetCore.Helpers | ||
namespace BookingSystem.AspNetCore.Helpers | ||
{ | ||
public static class ResponseContentHelper | ||
{ | ||
public static Microsoft.AspNetCore.Mvc.ContentResult GetContentResult(this OpenActive.Server.NET.OpenBookingHelper.ResponseContent response) | ||
{ | ||
return new CacheableContentResult | ||
return new Microsoft.AspNetCore.Mvc.ContentResult | ||
{ | ||
StatusCode = (int)response.StatusCode, | ||
Content = response.Content, | ||
ContentType = response.ContentType, | ||
CacheControlMaxAge = response.CacheControlMaxAge, | ||
ContentType = response.ContentType | ||
}; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// ContentResult that also sets Cache-Control: public, max-age=X, s-maxage=X | ||
/// See https://developer.openactive.io/publishing-data/data-feeds/scaling-feeds for more information | ||
/// </summary> | ||
public class CacheableContentResult : Microsoft.AspNetCore.Mvc.ContentResult | ||
{ | ||
public TimeSpan CacheControlMaxAge { get; set; } | ||
|
||
public override async Task ExecuteResultAsync(ActionContext context) | ||
{ | ||
if (CacheControlMaxAge != null) | ||
{ | ||
context.HttpContext.Response.GetTypedHeaders().CacheControl = | ||
new Microsoft.Net.Http.Headers.CacheControlHeaderValue() | ||
{ | ||
Public = true, | ||
MaxAge = CacheControlMaxAge, | ||
SharedMaxAge = CacheControlMaxAge, | ||
}; | ||
} | ||
|
||
await base.ExecuteResultAsync(context); | ||
} | ||
} | ||
} |
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
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