How Stack overflow updates questions with new activity - websocket

I was on a stack overflow page, without refreshing the page shows me that {number} questions with new activity, but if i check in Browser network panel, I can't see anything. How they keep on updating this count, without calling any background process.
Any idea how it happens.

Related

Slowly loading HDIV returns INVALID_HDIV_PARAMETER_VALUE and INVALID_PAGE_ID

I have some pages that load data slowly and will not have valid session data for the HDIV state while the page is rendering.
So if the user clicks a link during that time, they will get a Security Violation page because the HDIV state was not committed. Almost on all the components the link is loaded in a "href:"
This is not reproducible manually each time, but with automation is reproducible.
Any idea how to fix this?
I would avoid having an overflow to block clicking on the page until the page is fully loaded.

Browser Session causes Event Listeners to Increase

I have a page that checks if a user is logged in, and if they aren't, it redirects them to the login page and I've been experiencing some strange behavior with the Event Listener Count in the Chrome Dev Tools.
When the user is redirected to the login page, logs in successfully, then redirected back to the home page the Event Listener Count is around 6000.
When the user closes the tab, then navigates back to the home page (this time skipping the login screen because their session is still active) the Event Listener Count is only 4000.
What could cause this dramatic difference in the number of Event Listeners? The same page is being loaded both times, the only difference is the session is already established...
What is it about already having an active session that causes the Event Listener Count to drop so much?
Timeline tab shows current state of the tab memory not the page memory. It means that it's not necessarily true that it contains only memory allocated by a current website. If you have visited couple of pages using same tab then garbage from previous pages may still be in the tabs memory.
That's why in the new tab you've got expected number of 4000 listeners, while in the 'old' tab, that you have used to visit 'home page'->'login page'->'home page', you can see 6000 listeners.
You can force garbage collection using 'trash bin' button in the bottom left corner of the devtools. After you click it you should see a drop in number of listeners.
BTW You've got 4000+ event listeners on a webpage? This is a lot. I haven't seen a page that has more than 1000 listeners (this page has 80, twitter has 200 and gmail has 1000). If you are not working on some super complicated webapp (4 times more complicated than gmail) then you are doing something wrong. If you are using jQuery make sure that you know what $('ul').on('click','li',function(){}) does. If you are using vanilla JS, make sure you have read about event bubbling and how it can help you to reduce number of listeners.

Questions regarding backkey press of Wp7 Phone Application

Question regarding state of pages while deactivation and activation of page,i save the datas for that particular page alone.when i go back to previous page,by pressing back button,I am getting previous page which does not have data in it.To load the data in the previous page i need to get the instance of previous page ,is there anyway to get the instance of previous pages in Phone Application stack.,Other thing,is that On backkey Press,handling onbackkey press,by navigating to the new instance of the previous phone application page(what will happen to old instance of the previous pages).how to handle these scenarios?
You have asked some questions recently on page state. When an app is deactivated and activated again Windows phone 7.5 saves the page state. All that you need to do is to carefully handle the Page_Loaded and OnNavigatedTo events upon activation.
And if you want to override the back stack OnBackKeyPress, you can do so and navigate to any other page instance. But you should ensure you removed the back stack entry. otherwise causes many problems.(but this is not recommended)
NavigationService.RemoveBackEntry();

Classic ASP Logout Process

I'm working on a web application developed classic asp. It has logout button on the top menu which basically does the following actions
Session.Abandon()
Redirect to Index.asp, where users can login again.
After logging off users return to index.asp. But if users click back button the browser, they go to previous page. I don't want this to happen. I want a message saying that they are already logged off.I have implemented following steps
1.Add Response.Expires=-1 and Response.CacheControl="no-cache" at the top of each page.
2.On each page i'm checking session object to see it is not empty. If empty i'm creating a message saying that they are already logged off and need to log in again.
Now when users click back button after logging off, instead off showing logged out message, i get "Web page expired" message on IE8. I see the same behavior when users click back button on some page while logged in.
Any ideas how i can implement this better.
Thanks.
You can't stop users pressing back. A common scenario to work around this is that POSTs target a server page that displays no output but redirects to a new location instead (where the results can be seen).
There are additional non caching declarations that sometimes help:
Response.Expires = 0
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
I did read some time ago (hence inability to find link) that setting an expires to -1 can cause some browser to ignore it rather than have it expire immediately.
Even adding these extra cache controls won't stop some browsers from caching some things some of the time. FF quite often ignores a forced cache reload by the user, so you are in the browser makes hands to a certain extent.
Regarding your "Web page expired" message, this is (as mentioned) the result of the browser trying to stop you from resubmitting POST data (and potentially duplicating what you last did). The best way to get around this, and solve a number of other common UI issues on forms is to POST back to the same page, then if/when the action is completed, using a response.redirect to the same page, maybe with a URL encoded message to say "all done successfully". This allows your users to refresh and helps with the back button issue as most browsers now don't store properly redirected pages in their history.

How does Stack Exchange generate load new pages so fast?

Look at the profile pages of users that have asked more than 10 questions.
(e.g., https://webapps.stackexchange.com/users/2496/tobeannounced)
Now try skipping to questions 10-20, or page 2 of the questions they have asked.
The load for the new page is almost instantaneous.
How is this accomplished?
Simply be loading all the questions when the first page is loaded so that any additional pages that are called up load very fast? In other words, the additional pages are pre-loaded?
Using the network tab of Firebug for Firefox, you can see all HTTP requests being made. With this turned on you can see that clicking the next link fires off an HTTP request which grabs the next page of questions (i.e. it is not preloading all the questions with the initial page load). It's a small request, small response, and the server replies really quickly, which is why it happens almost instantaneously.

Resources