-
Notifications
You must be signed in to change notification settings - Fork 0
Installation instructions: Tips and Tricks
You‘ve done all things to get your foosball table online asks yourself if you can do more? Good news - yes you can!
Node.js is still in heavy development and may crash randomly. To keep your server up and running you can use forever to watch and restart it. The application will resume started games.
We recommend to make use of a Content Delivery Network to speed up the frontend even more. To get the CDN setup right you need to maximize the caching of static files, therefore you’ll need a proxy like Nginx.
Generate a unique id for each deployment and write it into the rev.json file. We use the git revision number. You need also to setup a cdn domain where browsers can load the files, like e.g. cdn.mydomain.com. Configure this in your config.json.
The revision number assures that updated but not renamed files will be re-fetched after next deployment. Browsers are caching files by its full address.
If done correctly, you will see following URLs generated on the on the production server: http://cdn.mydomain.com//path_to_file and http://cdn.mydomain.com//league/path_to_file.
We‘re using Amazon‘s CloudFront (CF) as CDN. It costs just cents per month and is easy to use. Go to your account and setup it up as distribution service. This will proxy the request to the origin server and cache the file (by default: at least one day). Assign CF your cdn domain and set the origin server to your current server.
Now configure your proxy to strip out the revison number so CF can fetch the file. Using the revision id in the paths assures that the file linked within this URL will never change, so we can set the expiration date to its maximum.
location ~* ^/\w+/(.*)$ {
expires max;
proxy_pass http://mydomain.com/;
}
This forwards http://cdn.mydomain.com//path_to_file to http://mydomain.com/path_to_file. CF will never will fetch the again, until the revisions id change. Also browsers will never the request the file again, while it’s in the cache.