16

When you play a song in Spotify, some hard drive space is used to cache the file, so that it plays faster the next time it is selected.

Is it possible to clear the cache (without the use of third party programs if available eg CCleaner) to save on hard drive space ?

A cross-platform answer would be nice if possible (but is not essential).

Hennes
  • 64,768
  • 7
  • 111
  • 168
Simon
  • 4,437
  • 8
  • 39
  • 51

2 Answers2

18

You can adjust the maximum size of the cache so it doesn't grow so big, and the next time you start spotify it will shrink the cache down to the size you specify.

Close spotify, then open for editing the prefs file which is at:

Windows1: %APPDATA%\Roaming\Spotify\prefs

Linux "native"2: $HOME/.config/spotify/prefs

Linux snap: $HOME/snap/spotify/current/.config/spotify/prefs

Linux flatpak: $HOME/.var/app/com.spotify.Client/config/spotify/prefs

Add or modify the line starting with storage.size to the number of megabytes you want the cache to use. For example:

storage.size=512

To limit the cache to 512 MB.

Restart spotify and the new limit will take effect (you'll see the folder shrink down to the specified size if it is already above it).


1 On Windows, the %APPDATA% folder is usually something like C:\Users\<username>\AppData.

2 By native I mean the default package manager that installs things in the default UNIX-y locations, like /usr/bin: things like dpkg (or apt), rpm(oryum), pacman, etc. That is, as opposed to the newer generation of isolated package mangers like snapandflatpak` which install things into a sandbox.

BeeOnRope
  • 1,051
  • 1
  • 13
  • 24
  • 2
    Awesome info! Thanks! It works, but in Ubuntu the file is in a different directory: `$HOME/.config/spotify/prefs` – Eduardo Baitello Mar 27 '19 at 20:09
  • Great answer for Linux users - location was `$HOME/.config/spotify/prefs` as per the comment above from @EduardoBaitello and I had to add the line – Grease Aug 21 '19 at 20:27
  • 3
    Installed with Snap on Ubuntu this config file for me was found at `~/snap/spotify/current/.config/spotify/prefs` – Alden W. Jul 13 '20 at 14:08
  • On my Ubuntu the size configuration did not work. In `prefs` I have the line `storage.size=1024` but still the cache folder became 10 GB – Jacques Nov 17 '20 at 09:08
  • @Jacques the cache folder holds more stuff than just the cached audio. For me 4096M resulted in a 7.0G cache folder, meaning there is around 3.0G of other stuff. Not sure if this is intended but I presume the config just sets the audio storage limit. – ojrask Dec 01 '20 at 11:35
  • For flatpak the file is in `~/.var/app/com.spotify.Client/config/spotify/prefs` – Paul van Schayck Jan 02 '22 at 13:12
13

Found on Lifehacker:

When you play a song on Spotify, it uses some of your hard drive space to cache that file for faster playing later. Here's how to clear that cache if you need some extra disk space.

By default, Spotify limits its cache to 10% of your free space, which means the default setting should be okay—but if you've changed it, you could run into disk space problems. All you need to do is delete the files in the following folder (for your platform):

Windows: C:\Users\USERNAME\AppData\Local\Spotify\Storage

OS X: /Users/USERNAME/Library/Caches/com.spotify.client/Storage/

Linux: ~/.cache/spotify/Storage/

ale
  • 3,369
  • 6
  • 40
  • 52