Link to home
Start Free TrialLog in
Avatar of iukpo
iukpo

asked on

Detecting browser refresh

Is there any way to detect if the user has pressed the refresh button on the browser? The reason why I'm asking this is I'm trying to prevent an ASP script from re-running when the user presses the Refresh button (I know it sounds stupid, but someone out there is likely to do it!)
ASKER CERTIFIED SOLUTION
Avatar of djbusychild
djbusychild

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chandlermcc
chandlermcc

you could use a session object on the server side to track this sort of thing. the session wouldnt expire until the client closes the browser or it times out. refreshing the browser wouldnt effect the session
you could use a session object on the server side to track this sort of thing. the session wouldnt expire until the client closes the browser or it times out. refreshing the browser wouldnt effect the session
chandlermcc, imagine keeping all those in a session object on a website that has 100 pages and 10000 people visit the site and quit the browser without giving the site a chance to explicitly expire the session.... assume the integer stored in the session object is 4byes, that's 400 bytes per use who has seen 100 pages
and that's 4000000 bytes (or about 4MB)... don't you think that's a waste of memory?

the memory won't be able to be reclaimed for a while, either...

what you should rather do is tweak the page expiration so that the page will be loaded from cache rather than from the server
Yeah, that's why it was a comment and not an answer :) But I do agree with you. Funny, I've never heard anyone say good things about sessions...
Actually, I think Sessions are awesome. It's just that it's not all that great to be used here. ;) It's cool to have it to store something small and if kept at a minimum. ^^;