Skip to content

Cache directory on windows should be %localappdata% by default #1404

Closed as not planned

Description

@felicienfrancois

Currently cache directory is set to %APPDATA% by default on windows
https://github.com/atom/atom-shell/blob/master/docs/api/app.md#appgetpathname

But unless what is said on the doc page, there is a path dedicated to cache on windows: %LOCALAPPDATA%

According to https://en.wikipedia.org/wiki/Environment_variable#Windows,

LOCALAPPDATA is the temporary files of Applications. Its uses include storing of desktop themes, Windows error reporting, caching and profiles of web browsers.

So cache path should be set to %LOCALAPPDATA% and HTTP Cache, GPUCache, Local Storage, Cookies, ... should be moved to this dir.
It is important to do this because %APPDATA% is meant to be synchronised accross computer/devices unlike %LOCALAPPDATA%

Activity

  1. anaisbetts commented on Apr 12, 2015

    @anaisbetts
    Contributor

    Cookies and local storage should roam across users

  2. felicienfrancois commented on Apr 13, 2015

    @felicienfrancois
    Author

    @paulcbetts you may be right, that's sounds the most logical thing to do.

    But Chrome store all Browser data in LOCALAPPDATA. I don't know why.
    Maybe a compatibility purpose or because they want to handle roam on their own.

    Well in anycase, this issue is still valid for cache data (http cache and GPUCache)

  3. zcbenz commented on Apr 15, 2015

    @zcbenz
    Contributor

    Using %LOCALAPPDATA% for cache dir sounds good to me, but Chrome would still store cache in %APPDATA% as far as I know.

  4. felicienfrancois commented on Apr 15, 2015

    @felicienfrancois
    Author

    @zcbenz on windows Google Chrome store cache AND user data in %LOCALAPPDATA%
    And more precisely in %LOCALAPPDATA%\Google\Chrome\User Data.
    Google chrome does not use %APPDATA%.
    https://productforums.google.com/forum/#!topic/chrome/keN3Njx6gtM

    But %LOCALAPPDATA% have been introduced in windows 7. Previous version of windows does not have this environnement variables set nor the corresponding path. %APPDATA% is a fallback path on Vista and XP.

    So cache path should be set to

    process.env.LOCALAPPDATA || process.env.APPDATA
  5. jorangreef commented on Apr 15, 2015

    @jorangreef

    Dropbox recently updated their app to prefer LOCALAPPDATA over APPDATA (which roams).

    Often the app data is too large to roam, i.e. it's not just cookies.

  6. anaisbetts commented on Apr 15, 2015

    @anaisbetts
    Contributor

    Previous version of windows does not have this environnement variables set nor the corresponding path

    Atom Shell doesn't run on XP or Vista anyways, we don't have to worry about that

  7. anaisbetts commented on Apr 15, 2015

    @anaisbetts
    Contributor

    I'm not particularly excited about this change, I think we should close it. This is causing a problem for exactly zero users right now, but moving it has the potential to break everyone currently using Atom Shell who don't write a carefully coded migration routine, and end up breaking users. Zero benefit, non-zero downside == wontfix

  8. felicienfrancois commented on Apr 15, 2015

    @felicienfrancois
    Author

    @paulcbetts I understand your point, and I agree that this is a big concern.
    The cleaner way to fix this would be to creates new API methods and deprecates old ones which allow the change without breaking old usage

    If it is not worth considering, adding a notice on the documentation page would be fine

  9. zcbenz commented on Apr 16, 2015

    @zcbenz
    Contributor

    Chromium doesn't actually make use of the cache dir for browser's cache data, all cookies and caches are stored under appData dir. So making cache dir default to %LOCALAPPDATA% affects nothing unless user explicitly relies on the location of cache dir, but it also means it won't do what you wanted, e.g. move browser cache files to %LOCALAPPDATA%.

  10. felicienfrancois commented on Apr 16, 2015

    @felicienfrancois
    Author

    @zcbenz from my tests and from chromium documentation, Chromium uses the same paths than Chrome except it replaces Google/Chrome by Chromium: All in %LOCALAPPDATA%, nothing in %APPDATA%
    https://www.chromium.org/user-experience/user-data-directory

    Reminder:
    %LOCALAPPDATA% => HOME/Appdata/Local/
    %APPDATA% => HOME/Appdata/Roaming/

  11. bux commented on Oct 1, 2015

    @bux

    This is causing a problem for exactly zero users right now

    The atom folder is getting bigger and bigger and in our company "Roaming" is synced on every windows login/logoff. When using plugins you get tens of thousand node_module files that slow down the syncing process.

  12. anaisbetts commented on Oct 1, 2015

    @anaisbetts
    Contributor

    @bux578 The ~/.atom folder or node_modules isn't stored in AppData, you should file an issue about this in Atom

  13. zcbenz commented on Oct 4, 2015

    @zcbenz
    Contributor

    After a closer looking, I found that Chromium doesn't respect the cache directory at all in most places, for things like browser caches and GPU caches the path is hard-coded under userData and there is no way to change that. So I'm going to remove the cache path since it is useless and causes many confusions.

  14. 26 remaining items

  15. sommereder commented on Oct 25, 2016

    @sommereder

    But only Roaming gets synced here. Although I'm not sure how other companies handle that.

  16. kof commented on Apr 26, 2017

    @kof

    Why is this issue closed? this has been merged to develop branch, not to master…

  17. aabuhijleh commented on Nov 5, 2019

    @aabuhijleh

    After a closer looking, I found that Chromium doesn't respect the cache directory at all in most places, for things like browser caches and GPU caches the path is hard-coded under userData and there is no way to change that. So I'm going to remove the cache path since it is useless and causes many confusions.

    This appears to still be the case in more recent Electron versions.

    Because I've tried to use app.setPath('cache', newLocation) in Electron 5.0.6 (on Windows) and it doesn't work as intended. The app still uses the userData path.

  18. kalbert312 commented on Mar 7, 2020

    @kalbert312

    Ran into this today. For a desktop app that might have local file system dependencies outside of the app data folders it makes more sense for %LOCALAPPDATA% to be the default if it's available as its basically safer. For example, my app lets a user create a project that references a local folder as a resource folder. I want to store the project file in the local app data folder to eliminate dealing with searching for project files across the system. It doesn't make sense for this project file to go to other machines in this case because the referenced directory belongs to the local system.

  19. emmkimme commented on Jun 24, 2021

    @emmkimme
    Contributor

    My MR (Customize Electron/Chromium cache location #18309) has been closed. does it mean, I'm able to redirect the cache to any location now ?

  20. pushkin- commented on Jun 24, 2021

    @pushkin-

    @emmkimme It was closed as dupe of this

  21. imakiro commented on Jun 29, 2021

    @imakiro

    Could we reopen this issue because this has a monumental impact on corporate backup sizes : for each user of roaming profiles on Virtual Desktops / Virtual Apps, VDI or similar technologies, those caches are backed up with the rest of the profiles because there is no way of excluding them at the source or put them someplace else.

    With a hundred users, a simple retention policy of keeping just 1 week of profiles, backed up once a day, eats a terabyte of useless data, for one simple app such as slack.

    The amount of storage space (think about the CO2 is you're sensible to that) wasted for such a simple thing as "put cache in Windows cache designated location, put user data where it belongs" is a bit boggling.

  22. emmkimme commented on Jun 29, 2021

    @emmkimme
    Contributor

    It was the purpose of this MR (Customize Electron/Chromium cache location #18309) to make the difference between cache location and user data location.

  23. imakiro commented on Jun 29, 2021

    @imakiro

    The MR #18309 you pointed to is indicated as duplicate of this one, is there some miscommunication somewhere?

  24. emmkimme commented on Jun 29, 2021

    @emmkimme
    Contributor

    It was my assumption, but it has been confirmed as duplicate so I expect to be able to redirect the location of the cache in the next version of Electron Else I will have to adapt/redo my MR over this new version.

  25. nornagon commented on Jun 29, 2021

    @nornagon
    Contributor

    I'm reopening this as it does seem like a reasonable request, but with the caveat that since we inherit this behavior from Chromium, it is not likely to be straightforward to change. It may come to pass that Chromium refactors in a way that makes it easier for us to make this sort of tweak possible, but without that or other in-depth work such as #19693, this may not be possible for a while.

  26. self-assigned this
    on May 23, 2022
  27. felixrieseberg commented on Jan 17, 2025

    @felixrieseberg
    Member

    Hey everyone! Thank you all so much for giving Electron a try and thinking about ways to make it better. As you can probably tell from how this issue has been open for ten years, so far it has never been important enough for someone to close it directly or to otherwise make the resources available for it to happen.

    If you're wondering what you can do to get this into Electron, great news - Electron is truly open source! We, the maintainers, welcome outside contributions - especially from individuals and companies interested in joining us in maintaining this platform.

    If you're reading this and are thinking to yourself "Alright, I'll do it!" - good for you! For smaller changes, you can usually open a well-tested and documented PR directly on this repository. For larger changes, I'd recommend that you start with a "request for comments". This will ensure that you don't spend a lot of time on a larger change without getting feedback about your approach first. Alternatively, you could always hire a consultant, either from the maintainer community our outside, to perform the work that's important to you.

    In short, I'm closing this issue because we're currently not planning this work, but if you care deeply about this issue, we'd welcome your contribution.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions