How to reset Sharepoint 2010 security token cache duration?

In case of claim based authentication, once an user is authenticated by SharePoint 2010 the security token cache is cached by default for 10 hours. However you can change the cache duration by using below powershell script.

 

1. Get the security token cache config.

$stsc=Get-SPSecurityTokenServiceConfig

 

2. Set the new expiration window.

$stsc.LogonTokenCacheExpirationWindow = (New-TimeSpan -second 30)

 

3. Update the configuration.

$stsc.Update()

 

4. Reset the IIS.

iisreset