Skip to content

Ask About HttpCachePolicy and HttpResponse.Cache #369

@Clounea

Description

@Clounea

Summary

HttpCachePolicy and HttpResponse.Cache are missing in .NetCore. I want to ask if there are equivalents and if there is plan to add them to adapter.

Motivation and goals

We need migrate code (an API in Sharepoint) to ASP.NetCore and we find that the APIs are not supported by ASP.NetCore.

In scope

  • HttpCachePolicy.SetLastModified
  • HttpCachePolicy.SetMaxAge
  • HttpCachePolicy.SetOmitVaryStar
  • HttpCachePolicyBase.VaryByHeaders
  • HttpCacheVaryByHeaders.Item
  • HttpResponse.Cache

Examples

  1. ServerAndPrivate cache settings
// cache settings: do not cache in the client, cache in the server. Give client timestamp.
HttpCachePolicy cache = context.Response.Cache
cache.SetCacheability(HttpCacheability.ServerAndPrivate);
cache.SetLastModified(context.Timestamp);
cache.SetExpires(context.Timestamp.AddDays(-1));
cache.SetMaxAge(TimeSpan.FromSeconds(0));
cache.SetOmitVaryStar(true);
  1. set VaryByHeaders
httpContext.Response.Cache.VaryByHeaders["Origin"] = true;

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIssues that have a PR open for them.needs author feedbackThe author of this issue needs to respond in order for us to continue investigating this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions