After receiving a JWT from the backend where even the public key is encrypted, I am left with only the encoded token. This token is appended to all of my app's http calls, but there are only 5 such calls - 4 get requests and 1 put request. The issue arises in that I can only verify the token's validity during the first 4 http calls; once the data is cached, I lose control over monitoring the token's expiration. How can I ensure that the user is logged out automatically when the token becomes invalid? Would implementing an interval to check the token's validity at regular intervals on a specific endpoint be a feasible solution?
The token expires in 3 hours, so would it make sense to periodically check the token's validity every 20 minutes by pinging the server?