Skip to content

Instantly share code, notes, and snippets.

@thefella
Created August 29, 2012 14:16
Show Gist options
  • Save thefella/3513221 to your computer and use it in GitHub Desktop.
Save thefella/3513221 to your computer and use it in GitHub Desktop.
Detect if browser request is a prefetch or prerender using PHP
if ( (isset($_SERVER["HTTP_X_PURPOSE"]) and (strtolower($_SERVER["HTTP_X_PURPOSE"]) == "preview")) or
(isset($_SERVER["HTTP_X_MOZ"]) and (strtolower($_SERVER["HTTP_X_MOZ"]) == "prefetch")) ) {
// Request is a prerender or prefetch
} else {
// Request is 'normal'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment