I've noticed that when I Response.Redirect to an .aspx page, it sometimes displays a cached page instead of actually executing the page and pulling fresh data from the database.
I'm not using output caching or anything special in .Net here -- this is a CRM, and the caching is either happening on the client or, perhaps more likely, automatically in IIS.
There is never a querystring involved, by the way. I'm passing a key via session. I know that if I used the querystring it would probably partially bypass the cache problem, but it's not an option in this case, and anyway what I really want is a deeper understanding of what's going on.
I did a little digging, and some people get around this by using Server.Transfer (which actually behaves differently than Response.Redirect and some of the details are not always desirable), and some other people said to set Response.Cache.SetCacheability(HttpCacheability.NoCache) on the page where I want to avoid caching.
I would like a better understanding of what's going on here, and possibly a best practice -- for one thing, I thought .aspx pages were always flagged to avoid caching. Right?
Any thoughts?
If you redirect from the old domain to the new domain with the 301 redirection, browser caches it too, and prevent's you to enter the old domain. 📚 The definition of 301 and 302 redirections: 301 - means that the resource (page) is moved permanently to a new location.
Open the Developer Tools Panel by pressing CTRL + Shift + i on Windows or Option + Shift + i on Mac. When you see a developer tools panel open, look the the left of your URL bar to see a refresh icon. Hold the refresh icon for a few seconds until a menu appears. Then click Empty Cache and Hard Reload .
Response. Redirect sends an HTTP request to the browser, then the browser sends that request to the web server, then the web server delivers a response to the web browser. For example, suppose you are on the web page "UserRegister. aspx" page and it has a button that redirects you to the "UserDetail.
By default no headers designed to control caching are sent. This leaves the client to make up its own rules about how to cache the content sent.
So yes you would need something like:-
Response.Cache.SetCacheability(HttpCacheability.NoCache)
to ensure that a request (redirect or otherwise) does not simply use a cached version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With