简体   繁体   中英

Why does Rails start GETs only on page reload?

In my console, when loading a page, I get the usual list of executed commands like so:

Started GET "/employees" for ::1 at 2015-07-14 10:36:25 -0400
Processing by EmployeesController#index as HTML
  Employee Load (0.2ms)  SELECT "employees".* FROM "employees"
  Rendered employees/index.html.erb within layouts/application (7.7ms)
  Rendered layouts/_shim.html.erb (0.1ms)
  Rendered layouts/_header.html.erb (0.9ms)
  Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 438ms (Views: 433.9ms | ActiveRecord: 2.4ms)

But when I reload this page, I get the same previous block, but also a huge list of Started GET commands like so:

...

Started GET "/assets/static_pages.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400


Started GET "/assets/sessions.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400


Started GET "/assets/users.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400


Started GET "/assets/application.self-7c44b34571f9c6f50024ec815db695a00182b9937b48d97c4ac1515ab6b385a0.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400

...

There's almost 100 of these commands. They only appear when I reload a page and it doesn't matter which page is reloaded.

I don't think it's necessarily doing any damage other than possibly doing unnecessary work and clogging up my log but it'd be nice if I could find a solution.

Why is this happening? Is there anything I can do to prevent it?

These requests are the assets, which your browser is loading for your page. Since you are in development mode, they are served as separate files.

You could disable the logging of the assets requests, by adding this to your config/development.rb :

config.assets.logger = false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM