Skip to content

Commit dd783d6

Browse files
committed
Establish a CacheProfile topic view model, if needed
It shouldn't be necessary to access the `CacheProfile` topic via views since the cache profile attributes are set via the new `[TopicResponseCache]`. However, should it be necessary (e.g., to update the meta headers), the `CacheProfileTopicViewModel` allows one to be returned to the client. This isn't (currently) exposed via e.g. the `PageTopicViewModel` since it's not _expected_ to be needed, and we don't want to add potential overhead to _every_ page mapping.
1 parent 08db830 commit dd783d6

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*==============================================================================================================================
2+
| Author Ignia, LLC
3+
| Client Ignia, LLC
4+
| Project Topics Library
5+
\=============================================================================================================================*/
6+
7+
namespace OnTopic.ViewModels {
8+
9+
/*============================================================================================================================
10+
| VIEW MODEL: CACHE PROFILE
11+
\---------------------------------------------------------------------------------------------------------------------------*/
12+
/// <summary>
13+
/// Provides a strongly-typed model for feeding views with information about a <c>CacheProfile</c> topic, as referenced by
14+
/// the <see cref="PageTopicViewModel"/> and its derivatives.
15+
/// </summary>
16+
/// <remarks>
17+
/// Typically, view models should be created as part of the presentation layer. The <see cref="Models"/> namespace contains
18+
/// default implementations that can be used directly, used as base classes, or overwritten at the presentation level. They
19+
/// are supplied for convenience to model factory default settings for out-of-the-box content types.
20+
/// </remarks>
21+
public record CacheProfileTopicViewModel: ItemTopicViewModel {
22+
23+
/*==========================================================================================================================
24+
| DURATION
25+
\-------------------------------------------------------------------------------------------------------------------------*/
26+
/// <summary>
27+
/// Gets or sets the duration in seconds for which the response is cached. If this property is set, the "max-age" in the
28+
/// "Cache-control" header is set in the response.
29+
/// </summary>
30+
public int? Duration { get; init; }
31+
32+
/*==========================================================================================================================
33+
| LOCATION
34+
\-------------------------------------------------------------------------------------------------------------------------*/
35+
/// <summary>
36+
/// Gets or sets the location where the data from a particular URL must be cached. If this property is set, the
37+
/// "Cache-control" header is set in the response.
38+
/// </summary>
39+
public string? Location { get; init; }
40+
41+
/*==========================================================================================================================
42+
| NO STORE
43+
\-------------------------------------------------------------------------------------------------------------------------*/
44+
/// <summary>
45+
/// Gets or sets the value which determines whether the data should be stored or not. When set to true, it sets the
46+
/// "Cache-control" header in the response to "no-store". Ignores the "Location" parameter for values other than "None".
47+
/// Ignores the "Duration" parameter.
48+
/// </summary>
49+
public bool? NoStore { get; init; }
50+
51+
/*==========================================================================================================================
52+
| VARY BY HEADER
53+
\-------------------------------------------------------------------------------------------------------------------------*/
54+
/// <summary>
55+
/// Gets or sets which header the cache should vary by, if appropriate.
56+
/// </summary>
57+
public string? VaryByHeader { get; init; }
58+
59+
/*==========================================================================================================================
60+
| VARY BY QUERY KEYS
61+
\-------------------------------------------------------------------------------------------------------------------------*/
62+
/// <summary>
63+
/// Gets or sets which query string parameter keys the cache should vary by, if appropriate. Should be comma delimited.
64+
/// </summary>
65+
public string? VaryByQueryKeys { get; init; }
66+
67+
} //Class
68+
} //Namespace

0 commit comments

Comments
 (0)