Differential D21607 Diff 51438 src/applications/system/controller/robots/PhabricatorRobotsController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/system/controller/robots/PhabricatorRobotsController.php
- This file was moved from src/applications/system/controller/PhabricatorRobotsController.php.
<?php | <?php | ||||
abstract class PhabricatorRobotsController extends PhabricatorController { | abstract class PhabricatorRobotsController extends PhabricatorController { | ||||
public function shouldRequireLogin() { | public function shouldRequireLogin() { | ||||
return false; | return false; | ||||
} | } | ||||
final public function processRequest() { | final public function processRequest() { | ||||
$out = $this->newRobotsRules(); | $out = $this->newRobotsRules(); | ||||
// Add a small crawl delay (number of seconds between requests) for spiders | |||||
// which respect it. The intent here is to prevent spiders from affecting | |||||
// performance for users. The possible cost is slower indexing, but that | |||||
// seems like a reasonable tradeoff, since most Phabricator installs are | |||||
// probably not hugely concerned about cutting-edge SEO. | |||||
$out[] = 'Crawl-delay: 1'; | |||||
$content = implode("\n", $out)."\n"; | $content = implode("\n", $out)."\n"; | ||||
return id(new AphrontPlainTextResponse()) | return id(new AphrontPlainTextResponse()) | ||||
->setContent($content) | ->setContent($content) | ||||
->setCacheDurationInSeconds(phutil_units('2 hours in seconds')) | ->setCacheDurationInSeconds(phutil_units('2 hours in seconds')) | ||||
->setCanCDN(true); | ->setCanCDN(true); | ||||
} | } | ||||
abstract protected function newRobotsRules(); | abstract protected function newRobotsRules(); | ||||
} | } |