Cannot Override Cache Control Header.
See original GitHub issueI am using aspnetboilerplate version 5.13.0. I want response cache but it didn’t work no matter what i tried. Response Header has always cache-control: no-cache, no-store.
I tried the following;
- I just added the response cache attribute.
- Response Cache middleware and cache profile.
- I defined DefaultResponseCacheAttributeForControllers in WebCoreModule PreInitialize
Offical Documentation;
Abp provides a convenient way for you to configure the default Cache-Control header for all ApplicationService and Controller via IAbpAspNetCoreConfiguration
DefaultResponseCacheAttributeForAppServices: Used if Controller class does not define Microsoft.AspNetCore.Mvc.ResponseCacheAttribute
DefaultResponseCacheAttributeForControllers: Used if ApplicationService class does not define Microsoft.AspNetCore.Mvc.ResponseCacheAttribute
Note: Cache-Control is not configured by default. You may configure for all ApplicationService and Controller then use Microsoft.AspNetCore.Mvc.ResponseCacheAttribute at method/action level to override it.
Does anyone have a code sample? Because I couldn’t work correctly.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Override the "cache-control" values in a HTTP response
In no way. The Cache-Control (and other) response headers can be changed, but it will only be visible in the getResponseHeader method.
Read more >Cache-Control - HTTP - MDN Web Docs
The Cache-Control HTTP header field holds directives (instructions) — in both requests and responses — that control caching in browsers and ...
Read more >Cache-Control header being overridden by Cloudflare
So I set a page rule that covers my whole site and enabled Origin Cache Control, and now it seems to work. I...
Read more >Cache-Control - How to Properly Configure It
The "s" stands for shared and is relevant only to CDNs or other intermediary caches. This directive overrides the max-age and expires header....
Read more >Spring Security - Cache Control Headers
To do this, let's try overriding the cache control headers in a single handler method, by use of the CacheControl cache.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ismcagdas as follows,
Startup;
CoreModule;
@onur-ardal I think the problem is related to anti-forgery cookie, see the Notes section of https://docs.microsoft.com/en-us/aspnet/core/performance/caching/middleware?view=aspnetcore-5.0#conditions-for-caching. When I remove the
AbpAntiForgeryManager.SetCookie(Context);
I can setCache-Control
response header. So, it seems like this is by design of ASP.NET Core.