It would be nice if it worked without JavaScript though – an increasing pain-in-the-arse about the web generally. If only it were possible to have <iframe>s adjust to their content size, then we wouldn't need JavaScript at all!
It would be nice if it worked without JavaScript though – an increasing pain-in-the-arse about the web generally. If only it were possible to have <iframe>s adjust to their content size, then we wouldn't need JavaScript at all!
The software was built for a forum where the admin buttons was only for specific users, but the rest of the frontend was the same, so we used render_async to render some content for some users, and other content for admins, and the rest of the page could be cached statically.
We later changed it to use edge side includes with Varnish. An example of this is where you add the to your HTML:
<esi:include src="http://example.com/1.html" alt="http://bak.example.com/2.html" onerror="continue"/>
This will make Varnish fetch the URL(s), assemble the page and present it to the client, so your backend might see more requests, but the client only sees one.We recently implemented something that's async on the server, using a combination of pusher and sidekiq. This was particularly useful for cases where we access an external API and don't want to hold the unicorn process for too long. So when the response comes back we push it back to the client and display it. Would be interesting to maybe combine this approach with some server-push and background workers and what this gem is doing.
The inline includes that Varnish does is synchronous for the client, but asynchronous in your backend, your backend sees multiple requests.
I am interested in your pusher+sidekiq implementation, it is a good idea, but it might be a lot of work :)
1. Client sends a request via Ajax to a rails controller and simultaneously opens a private pusher channel to wait for a response.
2. Controller returns a response immediately and fires-off a sidekiq job.
3. The sidekiq job does the heavy lifting and pushes the results back via pusher (it can be JSON data, or a rendered partial).
4. Client receives the response via the pusher channel and shows it on the page.
Would love to see a write-up/notes/gist that demos this.
On the other hand, I really like to just throw HTML at the user without involving asynchronous JavaScript.