This is if you use Safari but some things can apply. With this latest root directory issue with High Sierra I was going to post this in that thread but it is not the same thing. I did some searches as I like to control this rather than let an automated system do it.
This is my method if anyone is interested. I do this every 2 to 3 weeks or if the system gets laggy. I lose the caches so in the first few minutes it is a little slow but quickly catches up.
Before we get going I permanently unlocked the Library so I forgot which key to press. I believe it is the Option key.
NOTE: Safari Preferences – Advanced - insure “show develop in menu bar” is selected
Clear Brower History
Safari - Develop - Clear Cache
Finder - Go – Library – Caches - Select all and Delete ALL.
Finder – Go – Library – Safari – Databases. (websites hide stuff in there)
1. Delete all Folders except - IndexedDB
2. Open IndexedDB and Delete all Folders
Safari - Preferences - Privacy - Manage website Data - Remove All. (It starts to repopulate pretty quickly but you get some of the more nasty stuff out)