...is from a real project: In a long form, a automatically validates against the server when changed. One test changed the , then immediately scrolled down many pages and submitted the...
...JavaScript periodically requests updates from a server to keep a in sync with the latest server-site data. Sometimes the test ended right after a polling request was sent, but...
...quite annoying when you have multiple deployment targets with different hostnames, e.g. a staging server and a production server. Using the hack below you don't need to configure default...
...request.protocol ActionMailer::Base.default_url_options[:host] = request.host_with_port end end If your application server talks only HTTP and relies on the web server for SSL, and if the web...
...malicious users can upload executables (like an .exe or .scr file) and use your server to distribute it. However, modern operating systems usually warn before executing files that were downloaded...
...be spoofed. When the user later accesses a file upload via an URL, the server will choose a Content-Type header based on the file's extension, regardless of what...
...Eventually you will want want the same detection logic to be available on both server and client side. This card shows how to get a Ruby method touch_device? for...
When an AJAX request raises an exception on the server, Rails will show a minimal error page with only basic information. Because all Unpoly updates work using AJAX requests, you...
...need to update the isDevelopmentError() function so it returns true when your particular development server shows an error. Unpoly >= 2.x // Only do this in development. This requires a `[data...
If your Rails application is using Webpack you need to serve assets on the same host as you application runs, otherwise you will see the following errors in your browser...
So if you are using awesome.vcap.me:3000 you need to start the webpack-dev-server with a different host than localhost (0.0.0.0): bin/webpack-dev-server --host awesome.vcap.me
...HTTP request for every asset and block other assets from being loaded until the server responds with 304 not modified. This will slow down your page loading considerably, and cause...
...unnecessary load on your servers. This card describes how you can setup your application in a way that browsers can properly cache your assets. The caching conundrum A caching solution...
If you are a makandra employee and are running your app on makandra servers, you can skip this step. All servers and developer machines at makandra are already configured...
...is not gitignored, or your changes are only valid for your machine, not any servers. Inside a Docker environment, this file might be ignored. How to fix. Globally:
We generally use multiple application servers (at least two) and you have to search on all of them if you don't know which one handled the request you are...
Rails application logs usually live in /var/www/ /shared/log. Web server logs usually live in /var/www/ /log. Searching through single logs with grep / zgrep You can use grep in...
...yourself. Do not manipulate package.json yourself. Yarn will do this for you. The dev server If might have noticed that adding webpack made you development server pretty slow. To increase...
...performance, open a separate terminal, and run bin/webpack-dev-server. The dev server will watch all your changes and compile everything automatically in the background. It will also auto-reload your code...
This is an attempt to list some of those things: On the server Always optimize: Don't do stupid things with the database. Avoid "n + 1" queries. Don...
...complicated table, or crazy visualization in a separate AJAX call? Move work from the server to the client. On the client The biggest issue on the client are loading times...
The maintenance mode is enabled on all application server as soon as the file /public/system/maintenance.html is present. Installation Add this line to your application's Gemfile: gem 'capistrano...
...application's web interface by writing a #{maintenance_basename}.html file to each web server. The servers must be configured to detect the presence of this file, and if it...
...and we want user names to be unique) The requests are accepted on the server by two worker processes who will now process them in parallel Both requests scan the...
...and we want user names to be unique) The requests are accepted on the server by two worker processes who will now process them in parallel Both requests scan the...
...response includes caching headers like Expires or Cache-Control, their validity depends on the server's Date header if present. Otherwise, the browser uses its local time. This can lead...
...its own local system time. This subtle behavior ensures that cookies remain consistent with server time, even if the client’s clock is incorrect. However, this can lead to unexpected...
...old to match the format created by pg_dump. The version of the PostgreSQL server doesn't matter here. For example, the official Ubuntu 20.04 sources include only PostgreSQL...
...workaround below. Background Creating and restoring a database dump has four components: the source server, pg_dump, the target server, and pg_restore. pg_dump will create a dump, and...
...used to redirects always resulting in a GET request. # Browser sends PATCH /foo HTTP/1.1 # Server responds HTTP/1.1 302 Found Location: /bar # Browser follows redirect PATCH /bar # Server responds
...is neither GET or POST. Some workarounds for this issue below. Fix on the server: Redirect with a modern status code If your redirecting action redirects with a HTTP status...
For our production servers we use Passenger as a Ruby application server. While it is possible to use Passenger for development as an Apache module, the installation process is not...
Get performance behavior that is closer to what you'll get on production servers Get a full-featured Ruby application server without configuration Usage Install Passenger Standalone with gem...
...CORS request, it adds an Origin: header with the origin (protocol + hostname + port). The server decides whether access is acceptable for this origin and adds the Access-Control-Allow-Origin...
...This way, CORS puts cross-domain access control in the hands of the requested server. Certain request types (mostly non-GET requests) require a special "preflight" request that checks server...
Your development server is usually running on an insecure HTTP connection which is perfectly fine for development. If you need your local dev server to be accessible via HTTPS for...
...to do this again in a month or a year. Next, start your application server for HTTPS. For a Rails application with Puma: bin/rails server -b 'ssl://0.0.0.0:3000?key...
If you want to know the currently deployed release, simply SSH to a server and view that file. $ cat /var/www/my-project/current/REVISION cf8734ece3938fc67262ad5e0d4336f820689307 Capistrano task When your application is deployed to...
...multiple servers, you probably want to see a result for all of them. Here is a Capistrano task that checks all servers with the :app role. namespace :deploy do
...request which is not what you want. Instead a blob is created on the server, the file is uploaded and your form receives a generated hidden input field carrying the...
...false. However, this will also disable a ll other routes like update_rails_disk_service_url which you will need. Another solution would be to call a power that returns...
...install a modern libvips version using our PPA. If you're hosting on makandra servers these packages have already been installed on your application servers. RubyGem In your Ruby code...
...send a default ETag by hashing the response body. While this still requires the server to re-render the view for unchanged content, you don't need to send unchanged...
...Network infrastructure may mutate your ETag I recommend to deploy your app to a server and see if you get the same ETag for two responses to the same URL...
...always is to prevent long-running queries in the first place, automatic timeouts can serve as a safety net to terminate problematic queries automatically if a set time limit is...
...both databases offer a variable to limit the execution time of queries. While they serve similar purposes they do have some differences in behavior and implementation. PostgreSQL Timeout Type: statement...