9

When I load thin like so:

thin start -e production

and try to access one of my pages, I get this in the log output:

cache: [GET /] miss
cache: [GET /assets/main-bd1ef4b153740fb69fd615304b87ad0d.css] miss
cache: [GET /assets/jqModal-8fa734bf4f58524b2799abd73ab7d34f.css] miss
cache: [GET /assets/jquery-544665ba1d5b4f793290421aafed85c9.js] miss
cache: [GET /assets/application-00b97aa2429046c0c43802f07b756b46.js] miss

These files exist in my assets directory under public.

I've run this command also:

RALS_ENV=production rake assets:precompile

I've tried just accessing the file /public/assets/application.js in the browser like this:

http://localhost:3000/application.js

Which gives me a 404 error (even though the file exists in /public/assets but the file can be read when I make a request to the file when the server is in development mode.

Anyone have any ideas?

1
  • What's the problem exactly - that there's a cache miss? (which can be expected the first time you request the file), or is it that those files are not accessible at all? They should be available at localhost:3000/assets/application.js etc.
    – Elad
    Feb 1, 2012 at 19:52

1 Answer 1

14

Rails serving static files is turned off in production (config/environments/production.rb) by default:

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false

The Thin server is not configured to serve the static assets, and so requests to your assets are failing.

4
  • This is looking like the fix I need. I will mark this as the answer once I deploy to heroku and know for sure.
    – aarona
    Feb 1, 2012 at 21:04
  • Is it advisable to use Thin as a server? The hosting company advised that and they have made a proxy towards thin. It works, but it might be not as fast I read somewhere. And Ryan, are you the guy from Spree? :-) Sep 8, 2014 at 18:25
  • I would not use Thin in production. I would use either Unicorn or Puma. Yes, I am the Ryan guy who was previously from Spree, but now I work for LIFX.
    – Ryan Bigg
    Sep 9, 2014 at 5:28
  • I believe you can get better production speeds from Unicorn and Puma.
    – Ryan Bigg
    Oct 7, 2014 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.