Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve assets in production faster #521

Open
til opened this issue Feb 25, 2017 · 2 comments
Open

Serve assets in production faster #521

til opened this issue Feb 25, 2017 · 2 comments

Comments

@til
Copy link
Member

til commented Feb 25, 2017

Today when we deployed the redesign, we first saw the new page without any styles at all. After some digging around, we found out that the asset files (css, javascript, images etc.) were properly compiled, into the directory public/assets, as is usual for rails apps in production. However, when the browser requested any of those asset files, it got a 404 not found. Why?

Usually, rails apps in production are run together with a webserver such as nginx or Apache, and those webservers are configured to serve static files from public by themselves. The Rails app can serve these files itself as well, but this is only meant as an inefficient fallback, and needs to be explicitly switched on with a configuration option. It is on by default in development mode, but off in production.

Our Apache server on Uberspace seems not to be configured to serve files from public, so we had to switch on that option, here is the change:

089d7dc

I don't understand at all why it has been working before the redesign. Baffled.

In its Rails docs, Uberspace recommends to let Rails serve the assets, saying this way is easier to set up: https://wiki.uberspace.de/cool:rails . But I think it would still be a lot better (faster pages!) to have Apache do it. Hence this issue - someone please research the Apache config change that is necessary to serve static files from the rorganize.it/public/, while still forwarding other requests to our app. The config change should then probably go in the .htaccess file on the server. Here is its current content:

[ror@schedar ~]$ cat html/.htaccess 
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteRule (.*) http://localhost:34567/$1 [P]
@lislis
Copy link
Member

lislis commented Apr 18, 2017

So, I found this https://serverfault.com/questions/78128/configure-apache-passenger-to-serve-static-files-from-different-directory
at I understand correctly, we try to get all requests to /public/ and then point Apache directly to it?

@til
Copy link
Member Author

til commented Apr 23, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants