Home

postredirectget

Postredirectget, commonly known as the Post/Redirect/Get (PRG) pattern, is a web development technique used to prevent duplicate form submissions and to provide a stable, bookmarkable URL after a form submission. The pattern works by having the client submit a form via HTTP POST, after which the server processes the data and returns a redirect response to a URL that uses HTTP GET. The browser follows the redirect and performs the GET request on the redirected URL, and the resulting page is rendered. Because the final page is retrieved with GET, reloading the page or pressing the back button does not resubmit the form data.

Typically the redirect is implemented with a 303 See Other status code, which clearly indicates that the

Benefits of PRG include preventing duplicate submissions, producing a clean, shareable URL for the results, and

following
request
should
be
a
GET.
Some
servers
or
clients
may
use
302
Found,
but
303
is
preferred
for
unambiguous
GET
semantics
after
a
POST.
The
pattern
also
enables
the
use
of
transient
messages,
such
as
“success”
notices,
by
storing
them
in
the
user’s
session
(often
referred
to
as
a
flash
message)
and
displaying
them
on
the
redirected
page.
enabling
user-facing
notifications
without
resubmitting
data.
Limitations
include
an
extra
round
trip
due
to
the
redirect,
and
the
pattern
may
be
less
suitable
for
certain
API
endpoints
or
highly
dynamic
multi-step
workflows.
Many
web
frameworks
implement
PRG
as
a
common
post-submission
strategy
to
improve
reliability
and
user
experience.