title: Good way for the client to know when a Twilio Capability Token has expired
body: <h1>Question</h1>
  <p>What is a good way for a client application to know when its Twilio Capability Token has expired?</p>
  <h1>More info</h1>
  <p>In my case, the client application is a Javascript application running inside a web browser.</p>
  <p>The reason I ask is because I want to make sure that the client application (running in the web browser) is always ready to receive incoming calls that are intended for it. It occurs to me that if the Capability Token that the client application is using has expired, then calls to that application will probably fail without its knowledge.</p>
  <p>The best solution I can thinking of so far is for the client application to keep track of the expiration on the Capability Token and automatically query the server for a new one shortly before it expires. (Using Javascript's <code>setTimeout()</code>?</p>
  <p>More ideally would be if <code>Twilio.Device</code> in the Javascript library had a callback that could be set for when the token was about to expire. That way the client could listen to that can request a new token at that time.</p>
  <p>Another solution could possibly be for the server to be able to extend the expiration of the client's Capability Token if it knows that a call has come into that is intended for that client. However this is functionality that Twilio may or may not provide.</p>
  <p>What is a good way to handle this?</p>