Previous Page
redirect()

Solar_Http_Response
redirectNoCache()

Next Page
setContent()

redirectNoCache()

public void redirectNoCache ( Solar_Uri_Action|string $spec, int|string $code default '303' )

Redirects to another page and action after disabling HTTP caching.

Parameters

  • (Solar_Uri_Action|string) $spec: The URI to redirect to.
  • (int|string) $code: The HTTP status code to redirect with; default is '303 See Other'.

Returns

  • (void)

Description

Redirects to another page and action after disabling HTTP caching.

This effectively implements the "POST-Redirect-GET" pattern.

The _redirect() method is often called after a successful POST operation, to show a "success" or "edit" page. In such cases, clicking clicking "back" or "reload" will generate a warning in the browser allowing for a possible re-POST if the user clicks OK. Typically this is not what you want.

In those cases, use _redirectNoCache() to turn off HTTP caching, so that the re-POST warning does not occur.

This method sends the following headers before setting Location:

<?php
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Expires: 1");
?>

See Also