GET Parameter


The getParameter() method is the HTTP request method most often used to request resources from a server through a client such as a browser. Since the transmitted page contents or files are requested using URLs, an indication of URL parameters is also important.

What are GET and POST requests?

Communication between clients and servers on the internet mostly takes place via the HTTP protocol (Hypertext Transfer Protocol). This enables a data exchange via request and response. When a user retrieves a URL via a client (e.g. their web browser), this client sends a request to the server, and the server provides an HTML page that is loaded by the user’s browser. The two most commonly used methods to enable this kind of communication are GET and POST.

GET request

When the GET request method is used, if a client uses the HTTP protocol on a web server to request a certain resource, the client sends the server certain GET parameters through the requested URL. These parameters are pairs of names and their corresponding values, so-called name-value pairs. These are added to the URL with a “?” sign and tell the server which resources are meant. The name and value are always separated using a “=” sign.

The syntax is as follows:

http://www.domain.com/index.html*?name1=value1

Multiple parameters, as well as entire lists, can be transmitted to the server. Here, the various parameters are separated using a “&” sign.

http://www.domain.com/index.html*?name1=value1&name2=value2

If the request is syntactically correct, the server sends a response. This initially contains certain status information about the request. This can, for instance, be whether or not the requested resource is available or when the request was made. The server does not first send the resource to the client but rather tells the client where the resource can be found. The browser then follows the instructions and asks for the resource from the server. This is when the browser finally loads the resource based on the location-based information provided to it by the server. The reason for this is that the HTTP protocol only allows for one-way communication. Every request only receives one response.

The GET parameter or GET request can be characterized with the following properties:[1]

  • Caching of the browser is possible
  • Preservation in the browser history
  • Saving as a bookmark is possible
  • Unsuitable for sensitive files
  • Length limitation (URL length)
  • Its primary purpose is to obtain data

However, it is advisable to only use the GET parameter to request files that are not security-relevant, as the data is transmitted via the URL.

What is the difference between GET and POST requests?

With a GET request, information is sent to the server via URL parameters. However, with a POST request, additional data is supplied from the client to the server in the message body of the HTTP request. An advantage of the POST over the GET request is that it is more secure - it cannot be bookmarked, is difficult to hack, and is not stored in the browser history. This method is therefore more commonly used when sensitive information is involved.[2]

Importance for search engine optimization

URLs with parameters are also referred to as dynamic URLs. Changing the parameters results in a new URL, and the page contents can change dynamically. For example, if an online shop has added products on a category page and a user loads this page using a browser, the new products will also be displayed since the page’s URL also requests for the changed content using the GET parameter.

The emergence of dynamic URLs when using getParameter() also has some disadvantages. Through the dynamics, it can happen that slightly similar content is generated on several URLs. The Duplicate content that results has a negative effect on page rank, which is why there are certain necessary measures to take into consideration from an SEO perspective. It is advisable to use a canonical tag so that the search engine crawler ignores the duplicate pages with the parameter-URLs. Parameters can be excluded from crawling with the Google Search Console. In this way, SEOs and Webmasters can optimize the Googlebot crawl budget.

A further aspect that becomes important through the use of the getParameter is the readability of the URL. The parameters in the URL are usually cryptic for the user and are not meaningful. For this reason, URLs with parameters should ideally be redirected to URLs without the corresponding parameter.

References

  1. HTTP Methods: GET vs. POST w3schools.com. Accessed on 05/08/2015
  2. [https://www.diffen.com/difference/GET-vs-POST-HTTP-Requests GET vs. POST diffen.com. Accessed on January 11, 2018

Web Links