In my new project, I have many dynamic data blocks on home page. for e.g.
- Latest news (displays top 2 news from DB, contains a small image, abstract text, and read more link)
- Deals of the week (displays top 2 deals from DB, contains a small image, Title, Subtitle, abstract text, and read more link)
To implement such things, I’m planning to go for one of the following approaches.
Approach A: storing such data in a separate HTML file, and render that using either Jquery ajax() call or MVC RenderPage()
Approach B: storing such data in a separate Text file, and render that using Jquery ajax() call
Approach C: storing such data in a separate XML file, and render that using Jquery ajax() call by reading XML and build HTML data
So can anybody suggest me which on is best method? I don’t to go for database interactivity during homepage load.
I would recommend the XML route. The reason why is that if this content is going to be updated frequently and displayed on your homepage, you want a relatively constrained data format.
If you have the data stored in HTML, you are storing structural and possibly graphical data along with the actual text to display. That gives the modifier the capacity to change (or accidentally break) how your content looks.
If you have the data stored as raw text, there is no given format to follow. If you need a title, author and text of an article to post, there is no predefined template saying that the person must include those data.
Storing as XML solves both these problems. You can store only the content, and then on your page parse it into HTML elements predefined by you, the page author. Furthermore, you can specify a document format that sets out the tags that are allowed in your document. This means that you as the page author have better control over what kind of data will be sent to you.