diff --git a/src/App.php b/src/App.php index 8d253ec76..a48e21571 100644 --- a/src/App.php +++ b/src/App.php @@ -695,6 +695,9 @@ class App $module = $router->getModule(); } + // Display can change depending on the requested language, so it shouldn't be cached whole + header('Vary: Accept-Language', false); + // Processes data from GET requests $httpinput = $httpInput->process(); $input = array_merge($httpinput['variables'], $httpinput['files'], $request ?? $_REQUEST); diff --git a/src/Module/ActivityPub/Objects.php b/src/Module/ActivityPub/Objects.php index f93c8b957..34d460951 100644 --- a/src/Module/ActivityPub/Objects.php +++ b/src/Module/ActivityPub/Objects.php @@ -46,8 +46,6 @@ class Objects extends BaseModule throw new HTTPException\BadRequestException(); } - header('Vary: Accept', false); - if (!ActivityPub::isRequest()) { DI::baseUrl()->redirect(str_replace('objects/', 'display/', DI::args()->getQueryString())); } diff --git a/src/Module/Friendica.php b/src/Module/Friendica.php index 73d5f633c..90869878e 100644 --- a/src/Module/Friendica.php +++ b/src/Module/Friendica.php @@ -115,8 +115,6 @@ class Friendica extends BaseModule protected function rawContent(array $request = []) { - header('Vary: Accept', false); - // @TODO: Replace with parameter from router if (DI::args()->getArgc() <= 1 || (DI::args()->getArgv()[1] !== 'json')) { if (!ActivityPub::isRequest()) { diff --git a/src/Module/Item/Display.php b/src/Module/Item/Display.php index a0d1ecbf5..b2ed43c5b 100644 --- a/src/Module/Item/Display.php +++ b/src/Module/Item/Display.php @@ -88,8 +88,6 @@ class Display extends BaseModule protected function content(array $request = []): string { - header('Vary: Accept', false); - if (ActivityPub::isRequest()) { $this->baseUrl->redirect(str_replace('display/', 'objects/', $this->args->getQueryString())); } diff --git a/src/Module/Profile/Profile.php b/src/Module/Profile/Profile.php index 31ef8d05b..5e5028cb8 100644 --- a/src/Module/Profile/Profile.php +++ b/src/Module/Profile/Profile.php @@ -80,8 +80,6 @@ class Profile extends BaseProfile protected function rawContent(array $request = []) { - header('Vary: Accept', false); - if (ActivityPub::isRequest()) { $user = $this->database->selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname'] ?? '', 'account_removed' => false]); if ($user) { diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 3267e9e9a..af40bc3b0 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -38,6 +38,8 @@ class Xrd extends BaseModule { protected function rawContent(array $request = []) { + header('Vary: Accept', false); + // @TODO: Replace with parameter from router if (DI::args()->getArgv()[0] == 'xrd') { if (empty($_GET['uri'])) { diff --git a/src/Protocol/ActivityPub.php b/src/Protocol/ActivityPub.php index eaf34669b..ad1e9367c 100644 --- a/src/Protocol/ActivityPub.php +++ b/src/Protocol/ActivityPub.php @@ -87,6 +87,8 @@ class ActivityPub */ public static function isRequest(): bool { + header('Vary: Accept', false); + $isrequest = stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') || stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/json') || stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json');