Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Mojolicious refresh

by LanX (Saint)
on Mar 18, 2020 at 01:18 UTC ( [id://11114409]=note: print w/replies, xml ) Need Help??


in reply to Mojolicious refresh

Yes there are many different approaches

That's a basic HTML question, which is agnostic of the underlying web framework.

Not sure if mojo offers specialized methods for all.

The classic approach is to reload the page.

Either by specifying

  • using an Ajax XMLhttprequest will reduce the necessary bandwidth and let it look more smooth if only small parts of the page are refreshed. (Needs JS again + DOM manipulation)
  • I'm aware that mojo supports web sockets to actively push new content to the webpage. Never used it, but it allows to better control the refresh from the server side.

Timtowtdi

I hope this overview will give you a starters to specify what you need and want.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Mojolicious refresh
by jo37 (Deacon) on Mar 18, 2020 at 22:10 UTC

    A more advanced technique consists in a client side framework like Angular where the page's content depends on some JS variables and is automatically refreshed whenever a variable's value changes. These changes may be pushed to the client via web sockets. This way page updates are minimal, smooth and happen immediately.

    Implementing this using Mojolicious::Lite on the server side is pretty easy. The real work has to be done on the client.

    Greetings,
    -jo

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
      > A more advanced technique consists in a client side framework like Angular

      I always thought that the benefit of Web sockets was that the action can be initiated from the server.

      I don't see the big difference to the AJAX/DOM point I listed.

      Or what's the advancement here?

      Speed?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        Avoid polling. Changed content is pushed to the client. This is AJAX based anyway.

        Greetings,
        -jo

        $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11114409]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found