Why do I get "cache: [GET /] miss" in production using WebRick?
Asked Answered
B

4

9

I cannot test my website in production mode using WebRick, as it is raising cache errors. In development and testing modes everything works perfectly.

I have set this option in config/environments/production.rb:

config.serve_static_assets = true

And then I ran:

bundle exec rake assets:precompile

Now I start up the server:

david$ rails s -e production
=> Booting WEBrick
=> Rails 3.2.1 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-31 19:52:35] INFO  WEBrick 1.3.1
[2012-01-31 19:52:35] INFO  ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2012-01-31 19:52:35] INFO  WEBrick::HTTPServer#start: pid=13329 port=3000

And when I go to http://localhost:3000 I get "We're sorry, but something went wrong.". In the terminal this is what it outputs:

cache: [GET /] miss

I'm stalled here. I have no clue in what to do.

Brynhild answered 31/1, 2012 at 18:54 Comment(3)
Did you changed the config.cache_store in application.rb ?Zoolatry
No, the application is new, I have not touched that file.Brynhild
Ok. Is there an error in the production.log ?Zoolatry
B
5

The problem is with the asset pipeline, which has to be well configured in production mode, as files are not precompiled automatically.

In my case, I was inserting a javascript file (with javascript_include_tag) that was only present in one page, so it was not included in the application.js manifest.

In that case, the asset pipeline is not precompiling the file when running assets:precompile.

In order to include the missing file, we have to edit config/environments/production.rb and add this line:

config.assets.precompile += %w( script1.js )

You will notice that this line already exists, but it's commented. Read the comment for more clarification. For more info, look at the official asset pipeline guide.

Brynhild answered 1/2, 2012 at 17:19 Comment(0)
R
0

This message about missing pages sends Rack::Cache middleware. If you dont need to use page caching in your rails app, just remove Rack::Cache in config/application.rb file:

require 'rack/cache'

module DemoApp
  class Application < Rails::Application
    config.middleware.delete Rack::Cache
    # ...
  end
end
Radiocommunication answered 31/1, 2012 at 19:57 Comment(1)
I wasn't the downvote - but telling the OP not to use a feature doesn't solve his problem.Telfer
D
0

As provisional solution, the following made the trick for me.

I changed the config/environments/production.rb file to change config.assets.compile line from false to true

# Don't fallback to assets pipeline if a precompiled asset is missed
 config.assets.compile = true
Dissemble answered 5/6, 2012 at 15:35 Comment(0)
C
0

To run application in production so you don't get cache: [GET /] miss Please Check you {project}/public folder , is their any assets folder exists if not then pre compile assets using bundle exec rake assets:precompile

once this is done :

set config.assets.compile to true in production.rb

Then restart you WebApp in production environment .

This approch worked for me hope will work for you .

If you are using rails 3.2.0 you will get [GET /] miss , but your application will work properly .

Commonalty answered 9/5, 2013 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.