Benefits of a RESTful URL

What are the benefits

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

URL

above

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

URL

Could there be any problems if we use the first url because we first used the first url and change the second url. This is in the context of the great ever-changing content on the website. Here the categories can be infinite in number.

+6
source share
5 answers

One of the differences is that the second URL does not specify categories, so the client code and really human users must first find some category name on the number mapping page, save these mappings, use them all the time and update the list when previously unknown categories are encountered, etc. Given the first URL, you are sure to know the categories, even if the page of the element does not mention them (but the site may still need a list of categories somewhere in any case).

Another difference is that the first format encodes two levels of categorization, while the second hides the number of levels. This can make things simpler or harder depending on how variable you want the depth to be (now or later), and if someone is translating code into two-level depth inadequately (for example, by analyzing URLs with a regular expression, capturing categories using two subgroups). Of course, the same problem can exist if they are still connected to the current depth of the categories listed on the id-> category category matching page.

+2
source

For a RESTful application, you don’t have to worry about the URL pattern. “Better” is one that is easier to create an application.

Regarding indexing and SEO, I'm sorry, but it is unlikely that search engines will understand your hypermedia API to be able to index it.

To better understand the URLs, see:

+3
source

From an SEO perspective, if this is what you want to be indexed by search engines , it’s best to first assume that the category names describe the content below them. Most engines prefer URLs that match your search query. However, if the category names may change, you probably need to support 301 redirects when they do.

+2
source

The first form will be better indexed by search engines and more convenient for the cache. The latter is both an advantage (you can reduce the load on your server) and a disadvantage (you do not always know people who are visiting your page again, and page changes may not apply directly to users: you need to take care to achieve this).

The first form also requires (somewhat) more heavy processing to get the desired element from the URL.

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

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

or better yet, rewrite through the URL,

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

where 12345 is the resource identifier. Then, when you access the data (which you would do anyway), they can do it quickly; and you just make sure the entry matches cat1, cat2 and item. Experiment with the page cache settings and don't forget to send an ETag (maybe based on ID?) And Last-Modified headers, as well as check the If-Modified-Since and If-None-Match header requests.

+2
source

What we have here is not a question of “better” indexation, but relevance.

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

For example: let's say we both want to evaluate “Red Nike shoes,” let's say (for the sake of simplicity) that we both got the same “score” for all SEO factors except the URL. In the first 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 at both lines, you can intuitively know which one is more appropriate ... The first one tells you: “Damn, yes, I'm all about Red Nike Shoes,” and the second one muttered “Red Nike Shoes” " Did you mean item code 12345? "

Also, having the KW part in the URL will help you get more relevance, and also help you win the “long tail” without much work. (sometimes KW in the URL may be enough)

But the problem goes even deeper. The second type of URL includes parameters, and those can (99.9%) lead to duplication of content. When using the parameters you will have to solve issues such as:

  • What happens to non-existent catid?
  • Is there a parameter check? (and how is the full proof?)

etc.

So why choose the second version? Because once you just have no choice ... :)

+2
source

Source: https://habr.com/ru/post/918831/


All Articles