A
A
Andrew2014-08-14 15:35:52
PHP
Andrew, 2014-08-14 15:35:52

What are and what is better Option (s) Web - frontend (client) for REST-server?

Hello!
I'm trying to create my first RESTful service, both for educational and possibly "not only" purposes :)) . But for now, I'm just designing. if possible ...
It seems like a picture is emerging, but after reading a bunch of articles and comments ... I did not find enough information about the client (it even looks strange why this aspect is not described in detail, everywhere they describe how to create a RESTful server, but nothing about the client) .
I imagine it like this -
There is a REST server, you can write a layer in PHP that will "curl" (curl) access the REST server, receive JSONs, and give browsers (users) what they want to see (or what we want to show them).
Question(s): Am I correct? How adequate is this in terms of performance? Isn't it "slow" because we end up with "double" requests. Those. I first contact the PHP server so that it processes the request and sends a new request to the REST server, etc. etc. with all the consequences, such as parsing the response, generating it into an object in order to work with it further.
But here I came across one question and the answer to it - HERE .
In short, it is proposed to transfer all the work to JS with AJAX requests to the REST server, and build a display using JS tools.
Question(s): How adequate are these options? And in the comments to the question in the link, by the way, a good question is what if I need Internet bots to be able to view pages.
What other options are there? What are the "correct" or "best" techniques/practices in doing this?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
_
_ _, 2014-08-14
@AMar4enko

All of the options you listed have the right to exist:
- both accessing the RESTful service from the server side in order to get the necessary information and generating static html from it
- and accessing the RESTful service directly from the browser script, which will independently visualize the received data
But it is important to understand the following - when you have a RESTful service, it can be accessed by servers, browser-based Single Page Javascript Applications, mobile applications, and even desktop clients, while a regular site is focused only on delivering server-side generated HTML content, and any integration, which is seamlessly performed when a RESTful service is present, results in an additional headache.

L
Lexxtor, 2014-08-17
@Lexxtor

Also interested in this question about search bots.
Recently, at codeschool.com, I began to study Angular.JS, it is just right for the REST API, it renders pages from JSON, for this, special attributes and expressions in brackets are inserted into HTML. But in order for Internet bots to index the site, people pre-render all pages using a special phantomjs library and store them on the server. This is an ugly crutch solution, I think.
I think that the solutions are as follows:
- Make a normal front-end, which, in the presence of JS, turns into a JS application that works through Ajax with a RESTful API.
- Wait for bots to learn how to execute JS.
- Instead of pre-rendering, make a simple content preview, with menus and pagination.

A
Alexey Firsov, 2014-08-21
@lesha_firs

you are familiar with `single page application` everything works on the client, the server only gives json using restfull, and html is built on the client using js, and we will give html to google using node.js or jvm.
p/s - reactjs is very suitable for this purpose.
api - facebook.github.io/react
here is a good report on react www.youtube.com/watch?v=aFUiULAC6zk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question