nginx - Rails production server not using latest javascript file -


i have server have set nginx , rails app. when load page, css , javascript links goes this:

<link rel="stylesheet" media="all" href="/assets/application-01b482b5cbd306773ee4d7bc86b222a5d0c9b1c2dc82302957bc752dc079f6aa.css" data-turbolinks-track="true" /> <script src="/assets/application-cc1e40cfd63b56dd14a482241c0d44cc69c37206eeeb546d3f88ce94e09f8abc.js" data-turbolinks-track="true"></script> 

the problem when load page, getting error 404 not found javascript file /assets/application-cc1e40cfd63b56dd14a482241c0d44cc69c37206eeeb546d3f88ce94e09f8abc.js curiously, not css file.

also, every time change of javascript in rails , deploy application (and therefore javascrpt gets compiled,but javascript fingerprint stays same!, should changed).

my production.rb file looks this:

rails.application.configure   config.cache_classes = true   config.eager_load = true   config.consider_all_requests_local       = false   config.action_controller.perform_caching = true   config.serve_static_assets = false   config.serve_static_files   = false   config.assets.js_compressor = :uglifier   config.assets.compile = true   config.assets.digest = true   config.assets.version = '1.0'   config.assets.precompile =  ['*.js', '*.css', '*.css.erb'] end 

and nginx configuration file looks this:

upstream rails {   server localhost:3000;   server 127.0.0.1:3000;   server 127.0.0.1:3001;   server 127.0.0.1:3002; } server {   listen   80;   server_name my_site.com www.my_site.com;    root     /home/httpd/projects/my_site/current/public;   index    index.html;    location ~* ^/assets/ {     add_header last-modified "";     add_header etag "";     gzip_static off;     expires max;     add_header cache-control public;   }    location / {     proxy_set_header  x-real-ip  $remote_addr;     proxy_set_header  x-forwarded-for $proxy_add_x_forwarded_for;     proxy_set_header  host $http_host;     proxy_redirect  off;     try_files /system/maintenance.html $uri $uri/index.html $uri.html @ruby;   }    location @ruby {     proxy_pass http://rails;     proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;     proxy_set_header host $http_host;     proxy_redirect off;   }  } 

and /public/assets/ folder contains:

application-d211d1f163557c0f66d9380e7d485b799459ef763d25d832edc6c238dc502ac1.css application-dd50fcd16cb3e12c063da05aa994afc5fe1558715e1af955cee8a633f5597171.js 

(where both version doesn't match version in generated html file, noted @ beginning of question.)

i have tried clearing tmp folder, didn't help. also, there doesn't seem nginx cache folder, haven't deleted it.

i using capistrano deployment.

what missing?

edit (additional info encounter issue):

if use capistrano deployment, make sure have app set roles deployment, if if isn't added roles, not invoke required steps when running thin:restart / thin:start. in fact, run predefined commands, except 1 starts/restarts server.

also, if starting server in production (in case thin) , receive loaderror: incompatible library version try find running server lsof -wni tcp:3000 , kill server. start deployment again , should work now.

rails in production mode uses manifest file .sprockets-manifest-<checksum>.json (located config.assets.prefix, public/assets/ default). file along assets generated rails assets:precompile rails 5. older versions have same concept, use rake , filename may different.

the manifest loaded rails when starts in production mode , used determine urls use assets, such javascript_include_tag or image_path, rails does not use or monitor files in app/assets/ in production.

if having trouble assets in production, make sure manifest present , refers correct files (its simple structure read manually).

if does, make sure rails processes got restarted after manifest created/uploaded, because old processes using outdated assets. rails restart should this, depends on how running processes.



also idea leave old asset files "online" short while when updating live site users loaded page have urls old assets, may not have downloaded them yet (in addition if literally opening page @ moment, things images in collapsible sections, or css backgrounds undisplayed classes may not have been downloaded).

take more care if hosting assets centrally on static file store multiple separate rails servers, while restarting them referring old assets , new.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -