jquery - Http 304 recieved for application heartbeat -


i trying implement application heartbeat using jquery.

the idea of change going reduce application session-timeout 30 minutes 10 minutes implement jquery application heartbeat every 2 minutes (120 seconds). heartbeat avoid user receiving application timeout when browser open if browser closed session should timeout in 10 minutes.

i've implemented heartbeat using jquery follows...

var heartbeatinterval = 120000; // send heartbeat every 2 mins var heartbeattimer = null; var retrycount = 0; var maxretries = 10;  $().ready(function() {           // register heart beat server keep session alive.     heartbeattimer = setinterval(function() {         $.ajax({             url: heartbeatajaxservleturl,             type: 'get',             error: function(data) {                 // server may down night or there may                  // network blip. such try send heart beat 10 times                 // if still failing kill heartbeat.                 retrycount = retrycount + 1;                 if (heartbeattimer != null && retrycount >= maxretries) {                     clearinterval(heartbeattimer);                 }             },             success: function(data) {                 // once have successful heartbeat reset retry count.                 retrycount = 0;             }         });         // when communication server lost stop heartbeat.         }, heartbeatinterval);   }); 

when open network tab in internet explorer developer tools can see heart beat working responses getting 304's instead of 200's. when did research on 304 explanation response code has http caching. bit unsure of the explanation honest.

enter image description here

but crux of problem user's session timing out when browser open regardless of heartbeat. i'm guessing means heartbeat i'm sending every 2 minites returning not hitting server?

can me explanation of might happening here , whey session timing out?

thanks

you can use cache:false option append timestamp url thereby making unique

reference $.ajax docs


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -