offline.php HTTP Status Code Suggestion (503)

Discuss Search Engine Optimization in relation to Joomla!. This forum will also have discussions on SEF/SEO Joomla! extensions.

Moderator: General Support Moderators

Locked
User avatar
Peter Clements
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 172
Joined: Tue Nov 08, 2005 12:58 pm
Location: Kent, England, UK
Contact:

offline.php HTTP Status Code Suggestion (503)

Post by Peter Clements » Thu Dec 10, 2009 1:58 pm

When taking a Joomla! site offline, incoming requests are issued a '200 OK' HTTP Status Code but really this should be '503 Service Temporarily Unavailable'.

This can be easily achieved by adding the following code to the top of offline.php, either in the 'system' template or if you're over-riding this file with your own template, then in your own offline.php file:

Code: Select all

<?php
header('HTTP/1.1 503 Service Temporarily Unavailable',true,503);
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 86400');
?>
You can also use "Retry-After" to specify to search engines when their crawler should return to try again (in seconds).

Perhaps this should be standard in the Joomla! 'system' template?

djohnson1215
Joomla! Explorer
Joomla! Explorer
Posts: 370
Joined: Fri Jun 13, 2008 7:49 pm
Location: Escondido, CA 92026
Contact:

Re: offline.php HTTP Status Code Suggestion (503)

Post by djohnson1215 » Thu Dec 10, 2009 5:33 pm

Peter Clements,

I kind of agree, but technically, the service (from the hosting server point of view) is still available. And because a 503 error code refers to the hosting server (technically), it is not correct to apply the same code to a off-line Joomla site. In essence, the off-line condition is publishing a "parked page" which technically should produce a 200 server code.

So I think you will be hard pressed to get Joomla developers to change this condition (IMHO).
D. Johnson
Technology is our advantage;
performance our passion

http://www.positionresearch.com

User avatar
Peter Clements
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 172
Joined: Tue Nov 08, 2005 12:58 pm
Location: Kent, England, UK
Contact:

Re: offline.php HTTP Status Code Suggestion (503)

Post by Peter Clements » Mon Dec 14, 2009 10:04 am

I still believe that '503' is the 'most correct' and that '200' is the 'most incorrect' when taking an entire site offline temporarily. If you had it offline for long enough and returned 200 then search engines might start to cache your offline message for EVERY page of your site that it knows about.

Just had a quick look and it looks like the Google Webmaster Guidelines suggest the same too:

http://googlewebmastercentral.[URL banned]. ... lebot.html
If my site is down for maintenance, how can I tell Googlebot to come back later rather than to index the "down for maintenance" page?
You should configure your server to return a status of 503 (network unavailable) rather than 200 (successful). That lets Googlebot know to try the pages again later.
http://www.google.com/support/webmaster ... swer=40132
503 (Service unavailable) The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.
I've seen many tutorials online suggest the same too, some suggest a half-way method is to use a '307 Temporary Redirect' but you can't specify a Retry-After value and it's still not giving out the correct status IMHO.

djohnson1215
Joomla! Explorer
Joomla! Explorer
Posts: 370
Joined: Fri Jun 13, 2008 7:49 pm
Location: Escondido, CA 92026
Contact:

Re: offline.php HTTP Status Code Suggestion (503)

Post by djohnson1215 » Mon Dec 14, 2009 4:04 pm

Peter Clements,

Good evidence. Good reply. You make a good point worth of further consideration. Not sure how to get your suggestion to the developers though. May be they are listening.
D. Johnson
Technology is our advantage;
performance our passion

http://www.positionresearch.com

User avatar
Peter Clements
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 172
Joined: Tue Nov 08, 2005 12:58 pm
Location: Kent, England, UK
Contact:

Re: offline.php HTTP Status Code Suggestion (503)

Post by Peter Clements » Thu Dec 17, 2009 2:49 pm


getknk
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Mar 17, 2009 4:00 pm
Contact:

Re: offline.php HTTP Status Code Suggestion (503)

Post by getknk » Sun Feb 21, 2010 9:00 pm

Thanks for the suggestion.

When you say top of the offline.php,
should i add below the <head> tag?

for example should i add the snippet in the first <php tag?

or anywhere in the <head> would do?
---------
Would be below example be OK?

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<?php
header('HTTP/1.1 503 Service Temporarily Unavailable',true,503);
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 86400');
?>
	<jdoc:include type="head" />
                 .......................

http://www.Yes2Exams.com
An online forum to discuss about Exams

User avatar
Peter Clements
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 172
Joined: Tue Nov 08, 2005 12:58 pm
Location: Kent, England, UK
Contact:

Re: offline.php HTTP Status Code Suggestion (503)

Post by Peter Clements » Mon Feb 22, 2010 12:45 pm

getknk wrote:Thanks for the suggestion.

When you say top of the offline.php,
should i add below the <head> tag?

for example should i add the snippet in the first <php tag?

or anywhere in the <head> would do?
Make sure it's right at the top, above/before any HTML is outputted (but ensure there is no whitespace/line breaks above your DTD, close the PHP tag on the line above the DTD), below the Joomla! security check, for example mine's like this:

Code: Select all

<?php
	defined('_JEXEC') or die('Restricted access');
	
	header('HTTP/1.1 503 Service Temporarily Unavailable',true,503);
	header('Status: 503 Service Temporarily Unavailable');
	header('Retry-After: 86400');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr">
	<head>
		<jdoc:include type="head" />


Locked

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 1.5”