The Store client and server interact through an HTTP interface, where the client issues requests, and the server responds. There are three types of requests, described below.
Request for Page Content to Experience Manager
As is typical with single-page applications, the Store client consumes page content as both HTML and JSON. As a rule of thumb, the Content-Type
is JSON for AJAX request and HTML for non-AJAX requests.
Content as HTML
A request for HTML content is typically the result of a non-AJAX HTTP request from the browser, which causes the client to be loaded (or reloaded, as the case may be). As such, this is the mechanism by which the client application is bootstrapped.
The user enters the home page URL into the address bar.
The Store client sends a request for HTML to the home page URL.
The Store server sends the OK response and index.jsp is rendered as HTML.
Content as JSON
The default behavior of the single-page application Store client is to intercept hyperlink clicks and translate those into AJAX requests. As such, link clicks generate a request for JSON content.
The user clicks on the home page link.
The Store client sends a request for JSON, typically using AJAX, to the home page URL.
The Store server sends the OK response and the home page content is rendered as JSON.
Request to an Oracle Commerce REST service
Oracle Commerce REST services provide an HTTP interface to Nucleus components. The Store CLIENT typically invokes a REST service to perform some commerce business function, for example, adding an item to the cart.
The user adds an item to the cart.
The Store client sends a request to the
addItemToOrder
endpoint.The Store server sends an OK response and the updated order data to the Store client.
Request for Static Assets
Most Web pages load other static assets such as JavaScript, CSS, HTML, and images, which form part of the complete page. Static asset requests are not handled by the Store server application but serviced directly by the application/web server, or alternatively, a content delivery network. A typical interaction could be as follows.
The user enters the home page URL into the address bar.
The Store client sends a request for HTML to the home page URL.
The Store server sends an OK response and index.jsp is rendered as HTML.
The browser requests some JavaScript.
The browser requests some CSS.
The application server returns some JavaScript.
The content deliver network returns some CSS.
Note: The number and nature of the requests is determined by the content of the HTML page.