Post / Redirect / Get

from Wikipedia, the free encyclopedia

Post / Redirect / Get ( PRG ) or Redirect After Post ( German  diversion after dispatch ) is a behavior pattern in the development of web applications . The pattern prevents the user from sending forms multiple times. PRG is also used in search engine optimization ( SEO ), especially for filter navigation in online shops.

background

Diagram of the double POST problem.

When submitting a web form using the HTTP request method POST , it can take some time for the server to respond to the request. If the user is impatient and GETreloads the form using a, the form can be resubmitted using a POST, thereby causing an undesirable condition.

For example, if the ordering process in a web shop takes too long, the user could become impatient, reload the page and try the ordering process again. This can lead to an unwanted duplicate order.

functionality

Diagram of Post / Redirect / Get

To avoid the double problem POST, when initiating the order process, the user is redirected to a page using the HTTP status code "303: See Other" , which waits GETfor the process to be processed successfully using the method POST.

If the user reloads the page before finishing editing, he will come back to the waiting page and cannot submit a new one POST.

Use in search engine optimization

Filter navigations in online shops (often also referred to as layered or facetted navigation) allow the user to filter the range according to various product features such as color, size, material, etc. From the point of view of search engine optimization, however, this function is problematic because it creates (near) duplicate content and an almost infinite number of additional URLs , which in turn leads to a waste of crawling budget.

The PRG method is an approach to solve these SEO problems in connection with filter navigation and is superior to other common solutions in the field of SEO that do not adequately address the problems. However, the PRG method is usually not supported by standard by current CMS and online shop systems and must be supplemented individually (example implementation for WordPress ).

Alternatives

Basically, there is the possibility of creating POSTa resource with a unique Uniform Resource Identifier (URI). If an attempt is made to create the resource again with the same URI, the server can reject the new one POST, for example with the status code "405: Method Not Allowed" or "409: ​​Conflict" .

Single page web applications

In a single-page web application , the "Submit" button can be deactivated POSTto prevent the method from being used again. However, this mechanism is not sufficient if the user reloads the page. The web developer should therefore take additional measures to prevent a corresponding error if possible.

An alternative is if the user is given the opportunity to review his last actions and to undo them. For example, a web shop can redirect to the list of recent orders after an order has been placed, so that the user can immediately recognize a double order and cancel the second order process.

swell

  1. ^ Ward Cunningham : Redirect After Post. In: Portland Pattern Repository . September 12, 2014, accessed May 7, 2017 .
  2. ^ Post-Redirect-Get. Retrieved May 19, 2018 .
  3. POST, GET & PRG-Pattern, Faceted Navigation and the use in SEO . In: Catbird Seat - Agency for Digital Marketing . February 11, 2016 ( catbirdseat.de [accessed May 19, 2018]).
  4. l ▷ SEO optimization for layered navigation with PRG pattern ✔ | JaJuMa blog. Retrieved on May 19, 2018 (German).
  5. Tobias Keller: Implementing the PRG Pattern in WordPress. August 26, 2018, accessed on August 28, 2018 (German).