Skip to content

Sprockets can't use cache, because SassCompressor#cache_key changes on every run #146

Open
tablecheck/dartsass-sprockets
#33
@ledestin

Description

@ledestin

Problem

Running a single system test takes about 50 seconds on a project with lots of SASS files. I've investigated Sprockets and found out that SASS files are processed each time a test runs, and Sprockets cache isn't used. And it is not used, because of a random cache key in SassCompressor.

SassCompressor is monkey patched by sassc-rails and uses a random #cache_key:

@cache_key = SecureRandom.uuid

Possible solution

Sprockets uses the following cache key:
@cache_key = "#{self.class.name}:#{Autoload::Sass::VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
https://github.com/rails/sprockets/blob/386ab2ba215f828602b6e6bfee9bfc95dc23d574/lib/sprockets/sass_compressor.rb#L46

By using the Sprockets @cache_key code, I was able to make the test 2x faster (50 -> 25 seconds).

Would it be possible to use a cache key that doesn't change on each run, when no other things have changed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions