-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TopicController
response caching
#89
Comments
Does this proposed We could have an extension method for default defining cache profiles, while allowing them to be added by the customer for more specific criteria. But this might complicate e.g., making minor updates to cache profile defaults. Regardless, can a cache profile be set programmatically? It doesn’t seem like it. If not, we’d need to store the cache profile values in OnTopic and set them via the |
The |
Ideally, we should establish a structure similar to:
|
From the
Then, on e.g. the public CacheProfileViewModel CacheProfile { get; set; } Where the public record CacheProfileViewModel {
public int Duration { get; set; }
public string Location { get; set; }
public bool NoStore { get; set; }
public string VaryByHeader { get; set; }
public string VaryByQueryKeys { get; set; }
} This way, if a cache profile is configured, then it will be automatically mapped as a reference. And, if it isn’t, the application can determine what defaults (if any) it wishes to use in the meta headers. |
Instead of relying on each and every implementation to optionally expose the cache profile via e.g. the
A challenge with this is that it would live in the
Another challenge with this is that it will need access to the current topic. One approach to this is to make it dependent on the Of course, if this filter solves the vast majority of cases, the exceptions can implement this via their e.g. |
“Filters can be added by type or by instance. If an instance is added, that instance is used for every request. If a type is added, it's type-activated. A type-activated filter means: An instance is created for each request.” I.e., we can inject a global instance with hard-coded dependencies, such as an optional default options.Filters.Add(new ResponseCacheFilter("Default")); |
The `[TopicResponseCache]` attribute operates off of the `TopicController` (or derivative) and will identify any `CacheProfile` topics associated with the `CurrentTopic` (defaulting to the `Default` cache profile) and use its attributes to set the HTTP response headers for the current request. This is compatible with the ASP.NET Core Response Caching Middleware. This satisfies the core of Issue #89 .
…ibute This tests the new `/Web/CachedPage/` stub data (8cbf7da) to ensure that the `Counter.cshtml` (ea40bbb) doesn't increment after two subsequent calls, and that the cache headers are correctly set. It also checks a `/Web/UncachedPage/` stub data (8cbf7da) to ensure that the `Counter.cshtml` (ea40bbb) _is_ correctly incremented, as a control case. The completes the primary requirements for #89.
Introduced the new `[TopicResponseCache]` attribute, which operates similar to the out-of-the-box `[ResponseCache]` attribute, except that it loads the `CacheProfile` from the `CurrentTopic` instead of from the attribute or ASP.NET Core configuration. This allows cache profiles to be centrally configured and managed via OnTopic, and associated with any page. Further, as this is applied to `TopicController` and all descendants, and works directly with the response headers, it is automatically applied without the need for implementers to e.g. customize their models or views. This satisfies the requirements for #89.
This was implemented via a new |
OnTopic 5.2.0 introduces support for response caching (#89), a new `ErrorController` for HTTP error codes (#91), and improvements to `ITopicMappingService` performance via optional `AttributeDictionary` constructors (#99), updates to the internal reflection libraries (#90), and caching of compatible properties (#102). In addition, it also includes a number of internal code improvements, such as adoption of new C# 10 capabilities (#96), including global using directives (#93).
Update
TopicController
to conditionally set content headers that will be recognized by e.g.ResponseCaching
middleware. This way, we can dynamically configure particular pages to participate in response caching based on a topic attribute (e.g.,IsCached
).To accommodate this, we'll need to determine whether this will operate off of a fixed profile, centralized configuration values, or per-page values.
The best bet might be to rely on cache profiles, but to allow those to be selected via a
MetadataList
attribute. This would permit settings to be configured per site and to vary per page, while still allowing those settings to be centralized.The text was updated successfully, but these errors were encountered: