Skip to content

Commit 16423fa

Browse files
committed
feat: Add Dataset Site caching
1 parent e73eee3 commit 16423fa

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

OpenActive.Server.NET/CustomBookingEngine/CustomBookingEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public async Task<ResponseContent> RenderDatasetSite()
154154
{
155155
if (datasetSettings == null || supportedFeeds == null) throw new NotSupportedException("RenderDatasetSite is only supported if DatasetSiteGeneratorSettings are supplied to the IBookingEngine");
156156
// TODO add caching layer in front of dataset site rendering
157-
return ResponseContent.HtmlResponse(DatasetSiteGenerator.RenderSimpleDatasetSite(datasetSettings, supportedFeeds));
157+
return ResponseContent.HtmlResponse(DatasetSiteGenerator.RenderSimpleDatasetSite(datasetSettings, supportedFeeds), this.settings.DatasetSiteCacheDuration);
158158
}
159159

160160
/// <summary>

OpenActive.Server.NET/OpenBookingHelper/Content/ResponseContent.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ namespace OpenActive.Server.NET.OpenBookingHelper
1111
/// </summary>
1212
public class ResponseContent
1313
{
14-
public static ResponseContent HtmlResponse(string content)
14+
public static ResponseContent HtmlResponse(string content, TimeSpan cacheControlMaxAge)
1515
{
1616
return new ResponseContent
1717
{
1818
Content = content,
1919
ContentType = System.Net.Mime.MediaTypeNames.Text.Html,
20-
StatusCode = HttpStatusCode.OK
20+
StatusCode = HttpStatusCode.OK,
21+
CacheControlMaxAge = cacheControlMaxAge
2122
};
2223
}
2324

OpenActive.Server.NET/OpenBookingHelper/Settings/BookingEngineSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,10 @@ public class BookingEngineSettings
3737
/// See https://developer.openactive.io/publishing-data/data-feeds/scaling-feeds for CDN configuration instructions
3838
/// </summary>
3939
public TimeSpan RPDELastPageCacheDuration { get; set; } = TimeSpan.FromSeconds(8);
40+
/// <summary>
41+
/// TTL in the Cache-Control header for the dataset site
42+
/// See https://developer.openactive.io/publishing-data/data-feeds/scaling-feeds for CDN configuration instructions
43+
/// </summary>
44+
public TimeSpan DatasetSiteCacheDuration { get; set; } = TimeSpan.FromMinutes(15);
4045
}
4146
}

0 commit comments

Comments
 (0)