Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ghostbear/f12ee429e07ba528fb36778be5c2c88c to your computer and use it in GitHub Desktop.

Select an option

Save ghostbear/f12ee429e07ba528fb36778be5c2c88c to your computer and use it in GitHub Desktop.
[Spotify] How to limit the cache size (Windows/Mac OS)

Credit to MadHatter

WINDOWS

Use your text editor of choice or if you don't have one use Windows Notepad
Opening with Notepad may or may not result in a fancy mess

  1. Close Spotify
  2. Open File Explorer and paste the following into the address bar %appdata%/Spotify¤
  3. Open the file named prefs with your text editor
  4. Change the numeric value following storage.size= . If storage.size= doesn't exist add it manually to the end of the file and assign numeric value. This value represents megabytes. One gigabyte equals 1024 megabytes. In the end, it should look something like this storage.size=1024
  5. Save the file
  6. Start Spotify
  7. The cache should be reduced; not exceeding the size that you entered
  8. To verify, check the size of the Data folder in the following directory %localappdata%/Spotify

¤ For the App-Version of Spotify on Windows 10 use %localappdata%\Packages\SpotifyAB.SpotifyMusic_xxxxxxxxxxxxx\LocalState\Spotify instead of %appdata%/Spotify, credit to @SawPsyder

Mac

Apple TextEdit.app works fine to open "prefs" or one can use some similar code editing program

  1. Close Spotify
  2. Open Finder and press ⇧ + ⌘ + G or Open Spotlight (⌘ + Spacebar) and paste the following into the address bar~/Library/Application Support/Spotify
  3. Open the file named prefs with your text editor
  4. Change the numeric value following storage.size= . If storage.size= doesn't exist add it manually to the end of the file and assign numeric value. This value represents megabytes. One gigabyte equals 1024 megabytes. In the end, it should look something like this storage.size=1024
  5. Save the file (⌘ + S)
  6. Start Spotify
  7. The cache should be reduced; not exceeding the size that you entered.
  8. To verify, check the size of the Data folder in the following directory ~/Library/Caches/com.spotify.client/
@SawPsyder

Copy link
Copy Markdown

For the App-Version of Spotify on Windows 10, the file is located under: %localappdata%\Packages\SpotifyAB.SpotifyMusic_xxxxxxxxxxxxx\LocalState\Spotify

There you have to add the line storage.size=1024

@shrddr

shrddr commented Jul 27, 2021

Copy link
Copy Markdown

This works for %localappdata%\Spotify\Data\ folder, but keeps downloading all songs from "Your library" to %localappdata%\Spotify\Storage\

@SawPsyder

Copy link
Copy Markdown

Since last month my storage usage grew to 1.32 GiB.
I did the test and set storage.size=512 and it reduced the usage to 810MiB.
So it got reduced by ~512MiB.

Meaning, it doesnt look like this setting effects all save-paths.
I checked the %localappdata%\Packages\SpotifyAB.SpotifyMusic_xxxxxxxxxxxxx folder for possible subfolders wich are now 512MiB in size and found %localappdata%\Packages\SpotifyAB.SpotifyMusic_xxxxxxxxxxxxx\LocalCache\Spotify\Data to be viable.

After setting storage.size=256 the folder %localappdata%\Packages\SpotifyAB.SpotifyMusic_xxxxxxxxxxxxx\LocalCache\Spotify\Data got reduced to ~256MiB.
But folders like %localappdata%\Packages\SpotifyAB.SpotifyMusic_xxxxxxxxxxxxx\LocalCache\Spotify\Browser were left with there original size. (In my case 174MiB - deleting this folders content doesnt seem to harm, it gets rebuild. Still dont recommend without further testing)

All in all this might mean that there is still some more work to do to really softlimit the storage usage. At least for the App-Version of Spotify

@dmwyatt

dmwyatt commented Sep 6, 2021

Copy link
Copy Markdown

Don't have a prefs file there and creating one and adding the line doesn't seem to change anything.

What I do have is a LocalPrefs.json file, but the schema doesn't seem to lend itself to adding anything about storage size:

{
    "os_crypt": {
        "encrypted_key": "A LONG STRING HERE"
    },
    "profile_network_context_service": {
        "http_cache_finch_experiment_groups": "None None None"
    }
}

@pawrequest

Copy link
Copy Markdown

what @dmwyatt said... any new solutions?

@TheMockinJay

Copy link
Copy Markdown

@dmwyatt go to the roaming spotify folder, not the local one.

@TheMockinJay

Copy link
Copy Markdown

what @dmwyatt said... any new solutions?

^

@nelitow

nelitow commented Jun 17, 2022

Copy link
Copy Markdown

To me, it reduced from 8.8Gb to 3.4. Does this file get overwritten on updates?
Worth noting:
https://community.spotify.com/t5/Live-Ideas/All-Platforms-Setting-for-max-Cache-Size-Allowance/idi-p/3474568/page/10#comments

@devnoname120

Copy link
Copy Markdown

Has anyone found a non-official solution to limit the cache size on Android?

@engwbc

engwbc commented Dec 27, 2023

Copy link
Copy Markdown

Don't have a prefs file there and creating one and adding the line doesn't seem to change anything.

What I do have is a LocalPrefs.json file, but the schema doesn't seem to lend itself to adding anything about storage size:

{
    "os_crypt": {
        "encrypted_key": "A LONG STRING HERE"
    },
    "profile_network_context_service": {
        "http_cache_finch_experiment_groups": "None None None"
    }
}

I quickly realised that is a different file. The one you need to edit is simply prefs.file. Provided that you are on Windows, I found that it is stored in: C:\Users\user\AppData\Roaming\Spotify

@dspjm

dspjm commented Jun 29, 2024

Copy link
Copy Markdown

Thanks for the solution.

The path of app version should be:
$AppData$\Local\Packages\SpotifyAB.SpotifyMusic_*******\LocalState\Spotify\prefs.
Generally just go to $AppData$\Local\Packages, search for spotify, open it. Search for prefs. There may be several. Choose the one under Spotify rather than user.

@Voltikor

Voltikor commented May 20, 2025

Copy link
Copy Markdown

On Windows, make sure to make both prefs files - one in the Spotify folder (in %appdata%) and the other inside the Users folder - read-only. Spotify likes to overwrite these.
Something else I noticed is that Spotify only appears to clear its cache on startup, so if you leave it open it won't stop at the desired size. Never mind, it does seem Spotify is managing cache properly, even if it takes a while to clean up.

It's a shame we can't disable caching, Spotify is straight-up storing entire songs once they're played. God save our SSDs.

@andywarrens

Copy link
Copy Markdown

On Linux (NixOS) I found the prefs fiile in ~/.config/spotify/prefs.
After setting it to 5000 and restarting Spotify, my 10Gb folder shrank to 5Gb (~/.cache/spotify/Data)

@cometaura

Copy link
Copy Markdown

Setting storage.size=0 seems to completely stop caching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment