6

What are the benefits of

 http://www.example.com/app/servlet/cat1/cat2/item 

URL

over

 http://www.example.com/app/servlet?catid=12345

URL

Could there be any problems if we use first URL because initially we were using the first URL and change to second URL. This is in context of large constantly changing content on website. Here categories can be infinite in number.

Harry
  • 4,705
  • 17
  • 73
  • 101

5 Answers5

3

In relation to a RESTful application, you should not care about the URL template. The "better" one is the one that is easier for the application to generate.

In relation to indexing and SEO, sorry, but it is unlikely that the search engines are going to understand your hypermedia API to be able to index it.

To get a better understanding in regards to the URLs, have a look at:

Community
  • 1
  • 1
Tom Howard
  • 6,516
  • 35
  • 58
2

One difference is that the second URL doesn't name the categories, so the client code and indeed human users need to look up some category name to number mapping page first, store those mappings, use them all the time, and refresh the list when previously unknown categories are encountered etc.. Given the first URL you necessarily know the categories even if the item page doesn't mention them (but the site may still need a list of categories somewhere anyway).

Another difference is that the first format encodes two levels of categorisation, whereas the second hides the number of levels. That might make things easier or harder depending on how variable you want the depth to be (now or later) and whether someone inappropriately couples code to 2-level depth (for example, by parsing the URLs with a regexp capturing the categories using two subgroups). Of course, the same problem could exist if they couple themselves to the current depth of categories listed in a id->category-path mapping page anyway....

Tony Delroy
  • 102,968
  • 15
  • 177
  • 252
  • Hi Tony, Thanks for your response, could you see any problems in using 1st URL if we are changing from 2nd URL to first URL. And if we have infinite number of categories. – Harry Jun 23 '12 at 17:56
2

In terms of SEO, if this is something you want indexed by search engines the first is better assuming the category names are descriptive of the content under them. Most engines favor URLs that match the search query. However, if category names can change you likely need to maintain 301 redirects when they do.

2

The first form will be better indexed by search engines, and is more cache friendly. The latter is both an advantage (you can decrease the load on your server) and a disadvantage (you aren't necessarily aware of people re-visiting your page, and page changes may not propagate immediately to the users: a little care must be taken to achieve this).

The first form also requires (somewhat) heavier processing to get the desired item from the URL.

If you can control the URL syntax, I'd suggest something like:

 http://www.example.com/app/servlet/cat1/cat2/item/12345

or better yet, through URL rewrite,

 http://www.example.com/cat1/cat2/item/12345

where 12345 is the resource ID. Then when you access the data (which you would have done anyway), are able to do so quickly; and you just verify that the record does match cat1, cat2 and item. Experiment with page cache settings and be sure to send out ETag (maybe based on ID?) and Last-Modified headers, as well as checking If-Modified-Since and If-None-Match header requests.

LSerni
  • 55,617
  • 10
  • 65
  • 107
2

What we have here is not a matter of "better" indexing but of relevancy.

And so, 1st URL will mark your page as a more relevant to the subject (assuming correlation between page/cat name and subject matter).

For example: Let`s say we both want to rank for "Red Nike shoes", say (for a simplicity sake) that we both got the same "score" on all SEO factors except for URL. In 1st case the URL can be http://www.example.com/app/servlet/shoes/nike/red-nice and in the second http://www.example.com/app/servlet?itemid=12345.

Just by looking on both string you can intuitively sense which one is more relevant... The 1st one tells you up-front "Heck yes, I`m all about Red Nike Shoes" while the 2nd one kinda mumbles "Red Nike Shoes? Did you meant item code 12345?"

Also, Having part of the KW in the URL will help you get more relevancy and also it can help you win "long-tail" goals without much work. (just having KW in URL can sometimes be enough)

But the issue goes even deeper. The second type of URL includes parameters and those can (an 99.9% will) lead to duplicated content issue. When using parameters you`ll have to deal with questions like:

  • What happens for non-existent catid?
  • Is there a parameter verification? (and how full proof is it?)

and etc.

So why choose the second version? Because sometime you just don`t have a choice... :)

Igal Zeifman
  • 1,146
  • 7
  • 8