Skip to content

Template caching #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iatsiuk opened this issue Feb 9, 2017 · 6 comments
Closed

Template caching #343

iatsiuk opened this issue Feb 9, 2017 · 6 comments

Comments

@iatsiuk
Copy link

iatsiuk commented Feb 9, 2017

I would like to introduce more standard-friendly folder for storing template files and make PR with the necessary changes. Are you guys interested in it?

var os = require('os');
var path = require('path');

function cacheDir() {
  var platforms = {
    'win32': function() {
      return process.env.APPDATA ?
             path.join(process.env.APPDATA, 'Local') :
             os.tmpdir();
    },
    'linux': function() {
      return process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache');
    },
    'darwin': function() {
      return path.join(os.homedir(), 'Library/Caches');
    },
    'default': function() {
      return os.tmpdir();
    }
  }

  return (platforms[os.platform()] || platforms['default'])();
}
@yyx990803
Copy link
Member

tmpdirs are cleaned up on system reboot, no? I think the offline feature needs the cached templates to be persisted?

@posva
Copy link
Member

posva commented Feb 18, 2017

I think it's much easier to have the same dir across all OS even if it's not standard. If you ever have a cache issue you can use the same command to clean it

@iatsiuk
Copy link
Author

iatsiuk commented Feb 18, 2017

tmpdirs are cleaned up on system reboot, no?

@yyx990803 Well, my example uses os.tmpdir() method only for uncommon platforms like 'freebsd'. All other folders are widely used for persistent storage of application's cache. Just have a look how ugly cache folder are on Windows:

screen

If you ever have a cache issue you can use the same command to clean it

@posva I can't use the same command because commands are different for windows and linux platforms. All platforms has own rules for storage of this data type and cli utils should respect that.

@egoist
Copy link
Collaborator

egoist commented Feb 18, 2017

Maybe change it to process.env.LOCALAPPDATA on windows if needed

@iatsiuk
Copy link
Author

iatsiuk commented Feb 18, 2017

I'll be very grateful if you move cache folder to ~/.cache on linux as well.

@posva
Copy link
Member

posva commented Feb 18, 2017

@iatsiuk Who cares about an ugly directory tree... You can hide them if you want.

@posva I can't use the same command because commands are different for windows and linux platforms. All platforms has own rules for storage of this data type and cli utils should respect that.

Actually, yes you can, it depends on the command. The point was that the folder being the same across different OS makes it easy to deal with any cache-related issue Because it doesn't matter where you are, you know what folder to deal with.

Therefore, having different cache dirs is a downside.

What are the benefits of such rules?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants