tags:

views:

56

answers:

2

I'm making an online dictionary. Now I have two options:

1) Use AJAX for retrieving results 2) Just use some regular PHP scripts

If I choose the first option more likely the online dictionary will have one page and it's fast. If I choose the second option I'll have more pages (separate page for each entry with it's own URL), but it's slower. Personally I like the second option, don't really like to much AJAX on pages.

What is your opinion? Cons and pros (for this certain case)?

Thank you.

+3  A: 

If you use the second solution (ie, several URLs, one per page/definition), your users will be able to bookmark URLs for each specific page, use those to come back to youor site or link to it, or send them to other people, or whatever they want -- which is good.

If you only have one and only one page for your whole website, people cannot link to specific pages/definitions ; they have no way to come back to one specific word ; and that's bad :-(

Same for search engines, btw (Even if not that important for search results) : if they only see one page, they will not index your content well... and you probably want your site indexed.

So, in your case, I would probably go with several distinct URLs (even the corresponding pages are all generated by the same PHP script, of course).
And same thing for search results : you probably want to give people the ability to link to search results, don't you ?


About the "speed" thing : well, with Ajax, you'll send one request to the server. Without Ajax, you'll still send one request (for a bigger page, I admit), plus the ones for the images, CSS, JS, and all.

You should read a bit about Frontend optimization (see Yahoo's Exceptional Performance pages, for instance) ; it'll help quite a lot, about that ;-)

Pascal MARTIN
Plus the ones for the images, CSS, JS, etc? Only if your caching is set up incorrectly. http://www.mnot.net/cache_docs/
David Dorward
@David : Or, if people arrive with empty caches -- see "40-60% of Yahoo!’s users have an empty cache experience and ~20% of all page views are done with an empty cache" on http://yuiblog.com/blog/2007/01/04/performance-research-part-2/ (OK, quite old ; but might still be accurate)
Pascal MARTIN
If new visitors land on the search page, their cache will be empty. Ajax or not, this is always the case. With an Ajax solution, they couldn't land on the result page directly. With a simple solution, they just download the data they would get from the search page anyway (which would then be cached if they go to the search page). "Having to download the pretty" isn't a disadvantage when the alternative is "Can't go there. Yah, boo, sucks!"
David Dorward
A: 

You could potentially use htaccess (assuming you're on a linux server) to give unique urls to each page which keeping one page for displaying content.

For instance:

http://yourdomain.com/s/sausage would point to http://yourdomain.com/page.php?id=426

Which then would pull from a db and show you the 426th result, which would be for sausage, hurray. You'd probably want to build a htaccess generator for this, or use a system of slugs and use regular expressions

htaccess would look like this:

$http://yourdomain.com/s/([^/]+)^ $http://yourdomain.com/page.php?slug=$1

this will send anything after http://yourdomain.com/s/ to page.php as a slug variable, then reference your database for that slug.

Not sure if that's in any way helpful.

andy-score