82

I have started trying out Sass for my css work. In the directory where my Css file resides I see a '.sass-cache' folder too. Can any one tell me why is this folder created and is it safe if I delete it.

thanks,

Pav
  • 1,156
  • 1
  • 7
  • 10
  • Why do you want to remove it? – cimmanon Feb 18 '13 at 13:00
  • @cimmanon I've had issues with .sass-cache inhibiting pushes to development environments when multiple developers use/change it. If it can be removed from the project folder, this would be better. –  Oct 08 '13 at 21:41

2 Answers2

92

By default, Sass caches compiled templates and partials. This dramatically speeds up re-compilation of large collections of Sass files, and works best if the Sass templates are split up into separate files that are all @imported into one large file.

Without a framework, Sass puts the cached templates in the .sass-cache directory. In Rails and Merb, they go in tmp/sass-cache. The directory can be customized with the :cache_location option.

If you don’t want Sass to use caching at all, set the :cache option to false.

You can configure the Sass cache location by setting a Sass option in your compass configuration file like so:

sass_options = {:cache_location => "path\to\tmp\sass-cache"}

Source: Sass reference

Ahmad Alfy
  • 13,107
  • 6
  • 65
  • 99
  • 3
    Is there any way to recover sass file from sass cache? – nit3ch Oct 22 '13 at 11:20
  • 4
    You can also use `--cache-location PATH` when using the command line. – Violet Shreve May 16 '14 at 14:52
  • 8
    If you're using **grunt-contrib-sass**, the relevant options are `cacheLocation` and `noCache`: https://github.com/gruntjs/grunt-contrib-sass – Seth Sep 15 '14 at 20:39
  • 3
    I'm fine with improving speed, but why then does it keep all the old ones? Causing you to end up with huge masses of files. – MrFox Apr 10 '15 at 13:06
9

If your main problem is "inhibiting pushes to development environments when multiple developers use/change it", you can add it to your .gitignore file. As stated in the other answer, Sass cache files speed up compilation based on whether a Sass file has changed since last compile.

In my experience it's standard practice to consider them temporary files, and omit them from version control.

RobW
  • 10,184
  • 4
  • 41
  • 40
  • This does not answer the question. The OP does not indicate a reason why they wish to remove it (the version control comment was made by someone else). There are legitimate reasons why one might need to destroy .sass-cache. – cimmanon Aug 19 '15 at 15:28
  • 1
    Missed that those were two different users. Leaving up as it's information that addresses one user question raised on this post. – RobW Aug 24 '15 at 17:33
  • 1
    I believe this answer answers the next obvious question one might ask. It's very useful, despite not on topic with the initial question. – Adriano May 24 '19 at 00:16