Render content on the server or at browser

Recommend this page to a friend!

      JS Classes blog  >  Can Apache 2.4 Match ...  >  All threads  >  Render content on the server or at...  >  (Un) Subscribe thread alerts  
Subject:Render content on the server or at...
Summary:Detect an ajax call on the server
Messages:2
Author:simon ball
Date:2012-03-03 15:16:59
Update:2012-03-11 05:36:42
 

  1. Render content on the server or at...   Reply   Report abuse  
Picture of simon ball simon ball - 2012-03-03 19:03:13
Hi there,

Thanks for making the podcast. I enjoyed listening to your podcast, a few of the subjects stroked a few chords with me as they are issues I have come across.

I would like to comment on the dilemma faced when deciding whether to render ajax called content at the browser or server.

I wholeheartedly agree that a site needs to be able to render content at the server. As developers or designers, we still need to create for the lowest common deliminator and that is a presumption that a viewer will not have javascript enabled.

However, when rendering content at the browser, we can save effort on both the server and users internet connection...so what do we do?

An answer can be to simply detect what kind of headers have been sent from the browser and check whether the call is ajax, even an extra get paramater can be provided as it's simple to spoof headers. That's what I do with the framework I have built.

Once the server knows what "path" has been taken to the site, the server can quite comfortably do the processing and send out the same response in a different format. Personally, I stick to formatting such content in XML; I really don't get the whole advantage behind using json.

Maybe you can cover the advantages/disadvantages to either approach some time???

Peace

  2. Re: Render content on the server or at...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2012-03-11 05:36:42 - In reply to message 1 from simon ball
If you need your pages that are rendered with data retrieved using AJAX requests to also be crawlable by search engines, it is better to do all the rendering on the server side.

Search engines like Google that support the !# convention will need to be able to retrieve the content from the server for the whole page that otherwise the users see being updated via AJAX.

So the duplication of effort of rendering both on the server side and on the browser side may not be worth the time and patience to develop and debug.