mirror of
https://github.com/friendica/friendica
synced 2025-04-22 11:10:11 +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: *');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue