In attempting to implement automatic logout on the browser-side after 30 seconds of inactivity, we thought of creating a /heartbeat
endpoint:
- when the user moves the mouse or types any key, a javascript callback is scheduled after 10 seconds, to call
PUT /heartbeat
. - if a callback is already scheduled, the previous one is cancelled - this is done to avoid an "avalanche" of
PUT /heartbeat
when the user types and/or moves the mouse continuously (while e.g. writing content). - then, every 60 seconds, a
GET /heartbeat
is issued - that checks how much time has passed since the last time this user's session was 'updated'. We can do this by checking the content of the beaker session table. If more than 30 minutes have passed, the endpoint returns an appropriate indication to Javascript, so the user is automatically logged out in the browser.
This would work fine, except for one minor flaw - the GET /heartbeat
updates the beaker session timestamp...
So, the question is - under Pyramid/Beaker, is there a way to create an endpoint that DOESN'T update the session timestamp?