Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serving assets is very slow in development

I have a standart rails 3 webapp with the default asset pipeline. All of a sudden, the assets took a very long time to load (my page loads went to ~1-2secs to ~1min). The server response time (/home) is normal, but some .css and .js files are pending for very long (up to 45 seconds). The only few assets that take this long are those provided by gems (eg: modernizr-rails/vendor/assets/javascripts/modernizr.js)

For example, for modernizr.js?body=1 :

Headers:

Request URL:http://dev.sharewizz.com:3000/assets/modernizr.js?body=1
Request Method:GET
Status Code:304 Not Modified

Stats:

DNS Lookup  5.00 s
Connecting  20.07 s
Sending     0
Waiting     10 ms
Receiving   3 ms

It it a problem with sprockets ? How do I know what's wrong ?

Notes: all other browsers behave the same. Edit: Actually the problem is only with chrome, not even safari. I've tried to launch my server with rails s on port 3000 and on port 80 (no changes)

If I access http://localhost:3000/assets/modernizr.js?body=1, most of the times it is instant, sometimes it wait for very long.

like image 620
Benjamin Crouzier Avatar asked Sep 03 '25 06:09

Benjamin Crouzier


1 Answers

Another option - HDD isn't fast enough for logs, just bump into this (suddenly) on my dev pc. Try to set this into config/development.rb:

# Expands the lines which load the assets
config.assets.debug = false #true

If you have a lot of assets, each one take the time to write into dev log, adding up to several minutes total.

like image 96
lifecoder Avatar answered Sep 05 '25 01:09

lifecoder