Increase thumbnail cache in Ubuntu
You might have noticed that with the thumbnail view enabled in Ubuntu (or, the Nautilus file browser) that thumbnails seem to have to be re-generated quite frequently. This is due to the cache size limit being set quite small by default, at just 512mb. This quick guide is to show you how to adjust this number to your liking, so that you don't have to wait around as much for thumbnails to re-generate.
Quick side note on video thumbnails
By default it doesn't seem like Ubuntu supports showing video thumbnails without you installing some additional required packages. Fortunately this is pretty easy to do. In most cases, all you need to do is install the following packages:
sudo apt install ffmpeg ffmpegthumbnailer gstreamer0.10-ffmpeg
After that thumbnails for most video file formats should start popping up right away, although in some cases you might have to restart Nautilus (
nautilus -q) or just log out and back in again if things still don't quite work.
In some cases you might have to delete the thumbnail cache folder completely, so if things are still not showing up as they should, you can try deleting the
~/.cache/thumbnailsfolder, then restarting Nautilus or logging out and back in again.
Adjusting the cache size
Alright, now onto the topic at hand. We'll install an easy to use GUI tool to make this adjustment. This tool allows you to tweak many settings so is handy to have around:
sudo apt install dconf-editor
Once you've installed that, open it up then read and accept the warning shown.
All settings are organized and browsed through in a folder-esque way. To find the setting we want to modify, browse to
org / gnome / desktop / thumbnail-cache / maximum-size or search for "maximum-size" in the search field. Click on the item shown and you'll be greeted with additional information, including a description of the setting, the default value and more.
Use default value button, which will then allow you to enter a custom value right below it. You can now enter the value you prefer, in Megabytes. For now I have chosen 4096, or 4GB, but you can choose any value you like, so long as you have the hard drive space for it of course. You can also optionally choose to set it to
-1 which disabled cleaning of the cache folder, meaning no thumbnails will ever have to be re-renegated, but it will also potentially forever expand in size as a result, though that depends on another, related setting.
The other setting found in the same "path" in dconf-editor called
maximum-age allows you to specify how old (in days) a cached thumbnail file can be before it is purged. By default this is set to 180 days, which I felt is fine for my needs, but you can choose to customize this to your liking too. Here, too, setting it to
-1 disables the purging of older thumbnails, so if you disable both you truly get an ever-expanding thumbnail cache with your machine never having to regenerate any thumbnail.
That's it. The changes are applied immediately once you hit the Apply button. You'll soon start to notice that thumbnails stop having to be re-generated as often, which makes browsing folders with many images a lot more convenient if you ask me.
I hope this little tidbit was helpful to you and make browsing your files a bit more convenient.