Faster Livereload -- possible to cache CSS?

Before using middleman, I used to use fire.app which is a very similar concept. I moved to middleman because it’s more open (fire-app is encapsulated in a jruby environment and it’s impossible to update gems) and I can see myself writing extensions for middleman.

What I noticed with fire.app was that the livereload was instantaneous – in dev mode the css was getting cached in temp files and only the changes would get re-compiled.

Currently I wait 4-7 seconds for livereload. With fire-app, a similar project would show changes within 1-2 seconds. Not much but it changes the feel and flow for the better.

Would this be feasible with middleman? Is this a direction that is worth exploring?

Does anyone see possible steps to take? I feel at home with ruby, (although I haven’t developed for the middleman app before) and would love to help if I can.

Hi @andreimoment, 4-7 seconds to reload doesn’t seem right, my apps reload instantly upon save. I’m just guessing here but it might be the way you have your config file setup.

Is there anything I could improve?

There are no sprites being generated, and the SCSS is pretty straightforward; I was experiencing similar delay from the very beginning of the project when the files were almost empty. I do use Susy, breakpoint, compass and Slim.

Note 2: Ruby 2 on Windows 7, 3GHz, 8GB RAM workstation.

Here’s my config.rb

configure :development do
  activate :livereload, :host => 'localhost'
end

set :css_dir, 'css'
set :js_dir, 'js'
set :images_dir, 'img'

configure :build do
  activate :minify_css
  activate :minify_html
  activate :minify_javascript
  activate :relative_assets
end

Here’s my Gemfile:

gem "middleman", "~>3.3.3"
gem "middleman-livereload", "~> 3.1.0"
gem "middleman-minify-html"
gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw]
gem "tzinfo-data", platforms: [:mswin, :mingw]
gem "compass", '~>1.0.1'
gem "breakpoint"
gem "sass"
gem 'slim', '~> 2.0.3'
gem 'susy'

Also, I am seeing the delay on manual reload, not only on change.

I updated one of my projects config to look like yours and there wasn’t any issue so I’m thinking we can cancel out an issue with the config. Strange, wondering if this is a problem with running it on windows.

@andreimoment this won’t fix your issue but should help in recompiling a bit faster. Try adding these two gems to your gem file.

gem ‘therubyracer’
gem ‘oj’

to

gem "middleman", "~>3.3.3"
gem 'therubyracer'
gem 'oj'
gem "middleman-livereload", "~> 3.1.0"
gem "middleman-minify-html"
gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw]
gem "tzinfo-data", platforms: [:mswin, :mingw]
gem "compass", '~>1.0.1'
gem "breakpoint"
gem "sass"
gem 'slim', '~> 2.0.3'
gem 'susy'

Both of these failed to install on Windows.

I checked the exact same site on my mac and you’re right, LiveReload updates within a second or less.

So I will chalk this to ruby+Windows and possibly do more of the development on OSX or Linux.