[kdewebdev-webdeveloper] test

Andrew Lowe andrew.lowe at manildra.com.au
Tue Mar 4 18:30:23 EST 2008


On Tue, 4 Mar 2008 22:40:16 Isaak wrote:
> Hey,
>
> Thank you Andrew and Chris for the informative responses.
>
No problems... 

> The reason I use XML for the news articles is because this is the way of
> caching them, the less load this will have on the database the more you can
> use the database for other stuff. News articles will first be entered into
> the database when created but to publish them on the webpage they will be
> cached into XML files. I admit that XML isn't the recommended way for a
> website such as the one I'm creating now (fansite), but to be honest I just
> wanted to use XML for the news articles because it's the first time I used
> XML for websites, even though it's not the best way it's still a good way
> to cache the news articles even though it's not very SEO friendly if I just
> use AJAX to load the XML contents. It's also true that the size will
> increase as news articles are added but I'm using the Apache deflate module
> so it won't be much difference as it's just a fansite.
>
> Another reason that I don't want to use PHP is because the filesystem is
> much slower than the database and XML is just a static file and the parsing
> will happen on the clients side using AJAX. And the XML file will allow
> others to easily use the contents of the file on their website(s).
>

Loading the file using PHP is always going to be much faster then using AJAX.  
The AJAX meathod involves much more network overhead - sending the javascript 
to the client with the page, and then the client determining the XML file to 
request, the server returning the XML file, then the client re-writing the 
original page, inserting the articles (and optionally determining which 
articles to display, if you do not want all articles displayed on one page), 
then the client re-rendering the page.  
If the articles are static at any given time (no determining if an article 
should be shown or hidden) then you could probably spit the index.html page 
straight out of the database using server-side code when an article is added 
(when you generate the XML file).  
If you wanted, you could publish the XML file when you publish the html file 
too.... and make it available to others via a link on the main page.

The reason I suggest not using AJAX is because some clients will not have 
JavaScript enabled (Firefox NoScript plugin, or just turned off in the 
browser).  This is done for security, and probably is a bit paranoid.  Also 
some mobile devices do not support javascript, or have limited support.  The 
big one is as you mentioned, search engines.

Using AJAX and XML for the sake of it is not really a good thing to do, as 
AJAX has its limitations and overhead.  A suggestion if you wanted AJAX usage 
would be to have your articles displayed with just a title and/or summary and 
click the article to load via AJAX the full article.  You would probably need 
to use PHP on the back-end to take the requests and pass back the right data, 
or you could just load a static XML file for each article.
An example would be the Slashdot "New" discussion format - where low rated 
comments are not displayed until you click the title of that comment, and 
they are loaded dynamically.
AJAX for a static page is probably not the best use of the technology...

PHP is pretty quick to do these types of things, and I think you will find the 
load on the database would be worth using if your data is already there... 
The load on the server is probably no more using php to load the xml file 
then it would be to process the two seperate requests (the index, plus the 
xml file via ajax).  For what you describe it is very little load for php.

However as you say - it seems like it the website is small and these things 
probably do not really matter.... 

> The information above also explains why including an HTML file isn't the
> best option for me for this project. I did give this a thought though.
>
Providing the xml file separately would be the best way to solve this 
problem... you could even have php generate it out of a database if you 
needed - the code would be very similar to generating html... You could even 
provide an RSS/Atom feed if you wanted :-)

Hope this will help

-- 
Andrew Lowe
    System Administrator & Programmer
        Information Technology
            Manildra Group

Email:   andrew.lowe at manildra.com.au
Phone:   02 4423 8270
Mobile:  04 1323 8270
Fax:     02 4421 7760 


More information about the kdewebdev-webdeveloper mailing list