3

Rails 3.1 loads pages terribly slow in development. It's processing them through the pipeline, one at a time, and takes way too long.

Is it possible to precompile my assets (which I'm not testing right now, so static files are fine) and have Rails not be responsible for serving them? Would that make things faster?

Update: Got a solution.
Richard Hulse has the correct answer to this question. rake assets:precompile will prebuild assets so they are served directly, without the asset pipeline.

But Frexuz's answer solves the problem of slow loading I've been having. Loading the Rails-dev-tweaks gem makes page loading in development markedly faster.

Jordan Warbelow-Feldstein
  • 10,510
  • 12
  • 48
  • 79
  • Add the settings for assets of the file `config/environments/development.rb` to your question, this should be the source of the slowness. – mliebelt Nov 12 '11 at 12:21

2 Answers2

6

I had the same problem! It could take from 2-4 seconds extra to load a page because of the assets.

Take a look here (a gem): Rails 3.1 is very slow in development-mode because of assets, what to do?

This made serving assets almost instant (server console says 1ms per asset), using the asset pipeline normally.

Community
  • 1
  • 1
Frexuz
  • 4,732
  • 2
  • 37
  • 54
3

Yes.

You can run the precompile task (in 3.1.1) and it will just work - the precompile task will give you assets without fingerprints as well as with, which is what you need in development mode. (Fingerprints are not added in dev mode).

Beware that you don't commit these to source control though.

What is more of a concern is the slowness. I have 4 stylesheets and 15 javascript files in my manifests, and it is only a bit slow on the first request.

What do you see in your logs when the assets are accessed? You should be able to see them being compiled on the first hit and each subsequent request should be a 304 not modified.

Also, do your config settings for dev match those in the asset pipeline guide? If you were compressing in dev mode with lots of files, this could be a source of slowness.

Richard Hulse
  • 10,383
  • 2
  • 33
  • 37