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.
Precompile your assets and enable asset pipelining for development env. This may however not load the changes that you make in your source code without restarting the server.
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:
If you have a lot of assets, each one take the time to write into dev log, adding up to several minutes total.
There is an issue in chrome where the browser tries a dns request and waits for a timeout (you can see in the developer tools / network tab if you hover on the colored timelines, it says waiting (30000ms or higher), receiving (4ms).
In the case you are soing something like this:
127.0.0.1 localhost.mysite.com
in hostfile, and accesshttp://localhost.mysite.com
in the browser), you might try to just access it with localhost on port 80:rvmsudo rails server -p 80
http://localhost
in chromeThat might solve the issue.