I want to know if it is possible that when the user has not typed or clicked on the application for a long time that the document becomes expired. also if the user has clicked on the refresh button, then the document becomes expired?

Can somebody show an example of how this can be done? I don't know whether it is php or javascript which does this.

Thanks