ASP.NET Pages Displayed Blank Due To Cache - asp.net

We recently updated a Joomla site running on IIS, which has a menu item that opens an ASP.NET Framework 4.8 page in an iframe. This page opens on every browser I've tested on multiple machines. The problem is that since yesterday when the new site was deployed, some users are reporting a blank page when accessing the new menu item. In most cases, asking the user to clear their cache will allow them to view the page. Most of the problems were with Chrome browsers, but this is probably due to it being the most popular browser.
So I think there is a caching problem on the web site with the ASP.NET page. I suspect that the few users who are having problems never close the web browser on their machine (most are business users). Is there a way force pages to expire and reload in an ASP.NET page?
Thanks.

You could loop through all the cache items and delete them one by one:
foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache)
{
HttpContext.Current.Cache.Remove(string(entry.Key));
}
Syntax Correction for ASP.NET 4.5 C#
foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache){
HttpContext.Current.Cache.Remove((string)entry.Key);
}

To expire web content, you can use some iis feature like Client Cache or output cache.
Client Cache:
This element specifies cache-related HTTP headers that IIS 7 and later sends to Web clients, which control how Web clients and proxy servers will cache the content that IIS 7 and later returns.
to set you can follow the below steps:
Open the iis manager.
Select the site or application.
Select the HTTP Response Headers feature.
In the HTTP Response Headers pane, click Set Common Headers... from the Actions pane.
In the Set Common HTTP Response Headers dialog box, check the box to expire Web content, select the option to expire after a specific interval or at a specific time, and then click OK. You can set time of expiration.
For more detail about output cache and client cache you can refer below article:
Client Cache
IIS Output Caching

Related

Is there a web server or application level setting that indicates to the browser that the page has been modified?

We have an issue where when we upgrade our ASP .NET web application, some customers still see the old pages (old code) instead of the new code.
Would like to know if there is a server or application level setting that indicates to the browser that the page has been modified and forces a download instead of loading from cache, without having to make any code change?
Thanks,
Sunil

Using Postbacks with a CDN

We have a Sitecore/Webforms based website that we'd like to run behind Akamai CDN however we're having an issue with ViewState MAC validation on our postbacks.
We've worked around this for most of the core forms on the site (by taking them out of the CDN cache and serving them direct for every user), but we're left with a simple form in the footer of every page that posts back to the server.
Currently we're seeing errors:
Validation of viewstate MAC failed.
I believe this is caused by the CDN caching the viewstate fields from the original request and these (obviously) not matching for other users.
As we are running this site on multiple servers, we already have the machinekey correctly configured (we've been able to use postBackUrl settings to post back to other pages/SSL instances/etc.) before we added Akamai.
As we're running Asp.NET 4.5.2 there's no way we can even attempt to disable viewstate MAC even if we thought it was a good idea.
Setting ViewStateMode=Disabled still leaves us with a tiny viewstate (presumably the MAC) which still causes problems.
Is there anyway we can remove the session dependence from the viewstate?
The basic steps we can use to replicate this:
Request page from Browser A - Akamai caches page.
Submit form from Browser A - Success!
Request page from Browser B - Akamai serves cached page.
Submit form from Browser B - ERROR!
Nope, Akamai CDN never caches POST requests. But its good idea to try adding the forms to do not cache list and try replicate the issue.

Sitecore doesn't show changes on page unless recycle AppPool

Sitecore Version: Sitecore 7.2
I have an control that queries web index to get item, but when new items are added or old items are edited, the changes won't show on page.
I tried:
Disable htmlcache in web.config
Republish items and go to web database to make sure they are in web
Rebuild web index and use the same query (from search.log) in Luke to check the query result
Clear cache using /sitecore/admin/cache.aspx tool
Recycle AppPool in IIS (only this worked)
The items are in web database and web index, just won't appear on page unless I recycle AppPool.
Per previous comments, you need to rule out IIS caching. This can be Kernel-mode caching and regular output caching. It can also be compression. If you have configured compression and identified the MIME type as static then IIS will create a compressed copy of the file in a temp dir.
Remember that items are also (potentially) cached, not just HTML. So you should disable all caching in all the various locations in config. Use the Caching Configuration Reference and Optimizing Performance documents from the SDN and work backwards.
You can use Sitecore's cache stats page to see if the components are being cached or not (at a sublayout/rendering level) http://mysite/sitecore/admin/cache.aspx. Try hitting the reset button there and reloading your page.
There are lots of caching levels in Sitecore.

ASP.Net has very high server time

I have a 32-bit asp.net application running in IIS 7.5. I am having an issue with the pages.
Mentioned the issue below.
Open a page. Hit the database through some action in the page.
Open another page in another tab. Now, the second page doesn't respond till the first page responds. The second page has no database hits in page load. It's just plain HTML.
This happens with all the pages in the application. I am not sure if it is because of IIS or my application.
Do you have sessions enabled? If yes, all requests will be run serially. If you can, try to avoid using sessions or only enable it where you need it.

HTML5 Offline - how to prevent browser from using cached page?

I work on a web application in ASP.NET and HTML5. I have a simple page Default.aspx. In its Page_Load handler I call 'Response.Redirect("xxx.aspx"). I also defined a manifest file, Default.appcache as I want my application to work offline (in such case I javascript methods are used for redirection). Browser cached the page as expected but a problem occured - even though server is online, browser uses the cached page. When user enters Default.aspx no call is sent to server. How can I prevent this behavior? I would like the browser to send a normal request to IIS if it is online and use cached page only when server doesn't respond.
I would be grateful for all suggestions.
You can't, pages in the cache are always served from the cache. The only way to update them is update the manifest and force new versions to be downloaded.
If you want one page to be served when online and a different one when offline then you should investigate the FALLBACK section of the manifest. Note that the page which references the manifest is always cached, so you need to set the fallback up on a different pair of pages.

Resources