Skip to content
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

Add more functions to HttpCachePolicy #507

Open
TaoziZ03 opened this issue Jun 24, 2024 · 2 comments
Open

Add more functions to HttpCachePolicy #507

TaoziZ03 opened this issue Jun 24, 2024 · 2 comments
Labels
up for grabs We'd accept a contribution for this

Comments

@TaoziZ03
Copy link

Summary

Can I add more functions to HttpCachePolicy?

  1. SetNoStore(): add no-store header
  2. SetETag(string etag): add etag header
  3. UpdateHeaders(): better support no cache scenario, set expires = -1, pragma = no-cache and omit vary.

Motivation and goals

Our legacy code has a custom wrapper of HttCachePolicy and was modfied throughout whole request lifetime. None of attribute and middleware fit in existing design. To skip the design change and migrate to .net core first, I hope to add these functions.

In scope

A list of major scenarios, perhaps in priority order.

Out of scope

Scenarios you explicitly want to exclude.

Risks / unknowns

Please kindly point out other files I should modify.

Examples

Give brief examples of possible developer experiences (e.g., code they would write).

Don't be deeply concerned with how it would be implemented yet. Your examples could even be from other technology stacks.

@dotnet-policy-service dotnet-policy-service bot added the Needs: Triage 🔍 Label added to new issues which need Triage label Jun 24, 2024
@twsouthwick
Copy link
Member

We'll take an implementation of this if you'd like to provide that

@twsouthwick twsouthwick added up for grabs We'd accept a contribution for this and removed Needs: Triage 🔍 Label added to new issues which need Triage labels Jul 11, 2024
@TaoziZ03
Copy link
Author

TaoziZ03 commented Jul 15, 2024

I hope HttpCachePolicy could have the same behavior as Framework version.

Framework reference:
Get/SetNoStore()
Get/SetETag()
UpdateCachedHeaders()

Repro:

// Here set `vary` and `Expires`
httpContext.Reponse.SetVaryByCustom("accept-encoding");
httpContext.Reponse.SetExpires(2d);
httpContext.Response.Cache.SetETag("ETag1");
....
httpContext.Response..Cacheability = HttpCacheability.NoCache;
httpContext.Response.Cache.SetNoStore();

Expected headers

Cache-Control: no-store, no-cache
Pragma: no-cache

ETag, Expires and Vary will ignored because later set cachebility to NoCache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
up for grabs We'd accept a contribution for this
Projects
None yet
Development

No branches or pull requests

2 participants