Prevent Browser Caching of 301 Redirect

Here's a handy PHP function to send a 301 redirect, with out the browser caching it.   In otherwords such that you can then remove the redirect at a later date, with out browsers still keeping a hold of it :-

function noCacheRedirect($url)
{
   header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
   header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
   header('Location: '.$url, TRUE, 301);
   exit();
}

Saturday 22 September 2012 at 06:12 am | ΒΆ | Coding | No comments
  • 1