1

I have the following code:

 public class cacheMiddleware: OwinMiddleware
    {
        public cacheMiddleware(OwinMiddleware next) : base(next)
        {
        }


    public override async Task Invoke(IOwinContext context)
    {
        context.Response.Headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
        context.Response.Headers["Pragma"] = "no-cache";
        context.Response.Headers["Expires"] = "0";
        context.Response.Headers.Set("Strict-Transport-Security", "max-age=31536000; 
                                     includeSubDomains;");
        await Next.Invoke(context);
    }
}

Which is supposed to have changed the Http cache control headers to have "no store, no-cache, must-revalidate", but when I check it in Chrome Dev tools, I always get no-cache. I get the following values in response header for SignalR calls - signalr/negotiate & signalr/start. Interestingly signalr/connect? & my other calls are working working fine as expected. Is there anything more to do for signalr/negotiate & signalr/start calls?

signalr/negotiate & signalr/start:

Cache-Control:no-cache
Connection:keep-alive
Host:10.0.211.202
Pragma:no-cache
Expires:-1
Strict-Transport-Security:max-age=31536000; includeSubDomains;

signalr/connect:

Cache-Control:no-cache, no-store, must-revalidate
Connection:Upgrade
Strict-Transport-Security:max-age=31536000; includeSubDomains;
Upgrade:websocket

I tried possible solutions from net but no luck. Referred Setting Owin Cache Control headers in ASP.net Web API & signalr doesnt allow cross origin requests &

Is there a reason I'm not able to change what's in cache-control from no-cache to no-cache, no-store?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.