Effective ways how to get data from the server [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
We are building webapp and I have troubles deciding how to get data from the server.
On frontend we have angularJS and HTML. On the backend we have NodeJS, MongoDB, Mongoose and Express. As a templating engine we user JADE.
Now, what is the best way to fill the templates? Getting the data on the server while loading the partial or load the data through AngularJS using $http?
I am looking for the most effective and fastest way. Any thoughts?

I'll suggest to separate the things a bit. Keep your backend independent and create an REST API which provides the data. Once this is done you may use simply http request to access the data. By following this approach you will be later able to use other frameworks or even other languages to get the information stored into your database.

Mixing client-side and server-side composition of content can be optimized in a broad sense if your infrastructure includes reverse proxies and such. I am speaking very broadly here, but things with less state, and less coupling of state to quickly changing data, can be moved closer to the edge of infrastructure and cached and vended to clients calling http "on their own." An example might be this hour's set of suggested products for a user profile independent of the actual buying that a customer is performing. The closer you get to data and activity that is bespoke to the user and very transactional in nature, the more you need to go deep to the server side to ensure information archtecture consistency.

There's really no need to use any kind of serverside html rendering when using Angular; just serve some old skool plain html files on any webserver and grab your data using $resource or $http. It's lightning fast -- there's no faster way than only transferring the essential data to the browser.
Besides, serverside rendering is soooooo 2012

Related

Send data continuously from flask api to javascript frontend [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
So I want to make a website which visualize in real time some simulations which take some time to compute and I would like to know the easiest way to do it.
For now, the javascript front-end get the final result in once from the flask api and show it to the user. I would like the backend to send the result of the simulation in real-time, with batch of data at time intervals while it still computes, and the frontend to display the results in real time without having to re-load the page each time. How could I do that easily ?
Thanks
There are two common methods for doing this:
Web Sockets
Server-Sent Events (SSE)
If the frontend of your application needs to speak to the backend very often, then it would be best to open up a web socket for this channel of communication. Here is a list of popular frameworks for commonly used languages, including Python: https://github.com/facundofarias/awesome-websockets
If the frontend of your application just needs to listen for updates, then it may be better to use open up an event stream with SSE. Note that this can be done nowadays in most browsers in plain JavaScript at the frontend, but the backend may be a little more involved. Since you're using Flask, you might want to take a look at Flask-SSE.

Does Javascript and Jquery languages are enough to make a working web messenger application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Can we make a web based messenger application through the use of just these two languages javascript and jquery?
You will at least need to learn some basics of HTML as well.
(Hopefully) you also want to style your application, which means you should learn at least some CSS.
As far as programming languages go you will however need to know JavaScript and can use jQuery (among other things) to manipulate DOM.
Many modern applications however user React or Angular heavily to make the application building process easier in the long run.
You will also need to store your data somewhere, which means either server-side code and learning how to use a database such as mySQL, MongoDB or CouchDB to name a few (noSQL such as MongoDB or CouchDB are probably more appropriate for a messaging app). Or make it easier on yourself and use Firebase or something similar to store and retrieve data as well as handle user account and authentication.
I know all this may seem overwhelming, but making web apps involves a lot of moving parts.
SUMMARY
If you are starting out, I would recommend simpler challenges than a web app, but if that is what you are set on, the easiest in my opinion would be:
HTML + CSS + JQUERY (this is how your app UI is handled)
JAVASCRIPT (connects UI and data)
FIREBASE (stores data and enables user management and authentification)
Resources to help you get started:
https://www.codecademy.com
https://firebase.google.com

What kind of data should be cached? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm creating an API with "PHP" that get all responses and data from DB I'll use "VueJs" to create the Front-End as SPA and Vue-resource to make http requests, is it better to use PHP or JS to cache and what kind of data should be cached.
Database will contain some texts and images only
Why caching is used?
When a particular resource is requested multiple times, it is often beneficial for developer to cache resources to give response quickly.
Where is caching used?
Caching has wide range of applications from system architectures to web software.
How caching works?
Cache works by temporarily storing highly requested resource in a fast access location, like RAM, which is much faster than secondary memory.
Popular caching strategies
Please have a look at this page
How to use caching in web applications?
This question has many solutions, but a popular approach is to use memcached object storage. It stores objects in main memory.
The server side code must handle the GET requests in layers, the request must hit the cache layer first, check if the object is in cache. If yes(Hit), send response, else continue serving request from next layer.

JavaScript Stack - Web Server and API Server: together or separate? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
We are working on a large scaled web app that built on top of javascript frameworks and libraries (node, express/sails, angular, mongo etc).
We need to have a backend that from one hand serve the web application but on the other accept API calls for data (from the same app but from other origins as well) - very common these days.
One of the decision we want to take is should we separate the backend for Web Application server and API server or put them together.
For example should we have an express running serving both or should express serve the web app, static content, auth etc and have a separate Restify server serving the data.
What are the pros and cons for each agenda?
A clean separation of concerns is always the way to go. If, as you said, your API-Server takes calls also from other Apps, I would suggest you separate the delivery of static files and your API. It leaves your more flexible in changing the way one or the other works. Another benefit is that your API only needs to worry about API Calls and not the delivery, which should make it answer even faster.
I'm gonna take this one even further and say: Use nginx to deliver your static Web-App files (if you are not working with server side templating). See also this Thread - nginx is faster with delivering static sources.
In my company, this is how we do it for every App and it turned out to work just great.
So the Pros:
Better performance for both - static delivery and API
Clean separation of concerns
More flexibility in changing one or the other
The only con is that you need to install and maintain two programs. But given that NodeJS is super easy to set up, that shouldn't be a showstopper.
EDIT
As state by mnemosyn in the comments, if you separate your apps, you should still pull every request through the nginx Server to avoid some same-origin-policie issues. Within your nginx, you just have to configure a virtual-host pointing to your NodeJS-App and then proxying all request to a specified path (for example /api/) to that VHost. You can read about it here.

Is angularjs a good fit for large datacentric enterprise web application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am trying to build a web application which will have many different pages. each page mainly shows data in table and various graphs based on data.
I want to decouple front end completely from the backend. for this reason I am considering angularjs.
My concern is following two points:
angular js is considered best for SPA style applications
angularjs will load the partial view when required and will load data through ajax, every page needs at least two seperate http requests to render the page.
Is it really a good choice to select angular or any better approach?
I think that using Angular is a good solution, I am working in a very big project, that manage a lot of data and angular is working perfectly.
There are a lot of advantages of using Angular. However, I think that it depends on your needs, if you don't need a rich experience of user, maybe you can select other option different from a SPA that could be faster, if you don’t have experience developing a SPA..
I think that in your case, it is most important choosing well the backend technology than the frontend technology, because the responsibility of managing the data is from the backend.
I hope that helps.
Angular JS is a good for these kind of applications.
1.) Angular JS simplifies your code.
2.) It builds on HTML so you don't have to learn something entirely new and it is fast to catch up.
3.) It has a large community so you can get help on topics easily.
4.) It is continuously evolving.
5.) It is based on MVC structure.
P.S: Read on dirty checking part of angular as it is considered best in some scenarios and not so good in others. It is considered to keep no. of objects to 1000 or less while using angular for good performance.
Hope that helps! :)
From my experience I would say yes, is good. But maybe you can see with your eyes some case studies and applications built with angular: builtwith.angularjs.org.
Check this blog post also: Building large apps with AngularJS.

Categories

Resources