mirror of
https://github.com/friendica/friendica
synced 2025-04-22 23:50:13 +00:00
Pagecache for frequently fetched pages
This commit is contained in:
parent
934a3a6721
commit
6eb9dff807
11 changed files with 151 additions and 26 deletions
|
@ -31,6 +31,7 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Protocol\ActivityPub\PageCache;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -50,6 +51,13 @@ class Objects extends BaseModule
|
|||
DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString()));
|
||||
}
|
||||
|
||||
$data = PageCache::fetch($_SERVER['REQUEST_URI']);
|
||||
if (!empty($data)) {
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
System::jsonExit($data, 'application/activity+json');
|
||||
}
|
||||
|
||||
$itemuri = DBA::selectFirst('item-uri', ['id'], ['guid' => $this->parameters['guid']]);
|
||||
|
||||
if (DBA::isResult($itemuri)) {
|
||||
|
@ -127,6 +135,10 @@ class Objects extends BaseModule
|
|||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
if (in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
|
||||
PageCache::add($_SERVER['REQUEST_URI'], $data);
|
||||
}
|
||||
|
||||
// Relaxed CORS header for public items
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ use Friendica\Model\Verb;
|
|||
use Friendica\Module\BaseSettings;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Worker\Delivery;
|
||||
|
||||
|
@ -373,7 +374,7 @@ class Account extends BaseSettings
|
|||
// or the handle of the account, therefore we check for either
|
||||
// "http" or "@" to be present in the string.
|
||||
// All other fields from the row will be ignored
|
||||
if ((strpos($csvRow[0], '@') !== false) || in_array(parse_url($csvRow[0], PHP_URL_SCHEME), ['http', 'https'])) {
|
||||
if ((strpos($csvRow[0], '@') !== false) || Network::isValidHttpUrl($csvRow[0])) {
|
||||
Worker::add(PRIORITY_MEDIUM, 'AddContact', local_user(), $csvRow[0]);
|
||||
} else {
|
||||
Logger::notice('Invalid account', ['url' => $csvRow[0]]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue