Windows 10 got the ability to clear temporary files automatically in a recent build. Starting with build 15014, a new option appeared in Settings. Here is how you can use it.
RECOMMENDED: Click here to fix Windows errors and optimize system performance
To clear temporary files automatically in Windows 10, you need to enable the new option. Open Settings and go to System -> Storage. There, you will find the option named "Storage Sense". Enable it and you are done.
But the built-in auto cleanup feature is new to Creators Update. Files stored in Recycle Bin for more than 30 days will be deleted for example as part of this cleanup.
The user can customize this behavior. To do this, click the link "Change how we free up space" under the switch.
The related page will be opened:
There, you'll see two options. One is Delete temporary files that my apps aren't using.
It is a good idea to keep this turned on. Temporary files are created by various Windows services, installed apps and tools. Temporary files can be safely deleted after the process which has created them has quit. However, this does not happen often, so the system temporary directory or the app's temp directory continues to store them and fills your disk drive with junk. When this option is enabled, Windows will delete them automatically and keep you drive clean besides saving your disk space.
If you do not have Windows 10 Creators Update installed yet, it is not a problem. Windows ships with a tool to clean up files called Disk Cleanup. It can be automated using Task Scheduler or by simply creating special shortcuts to cleanmgr.exe with various switches.