Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2022-09-21 14:58:14 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2022-09-27 20:51:11 +0300
commit485b916cdf140289510571ec8573f92435057af9 (patch)
tree25089bf95dc4d4d5cb5106644259a664ca25a9e6 /lib/Controller
parenta4edc5150863563ad36425e3857cfca51393e979 (diff)
Improve HTTP caching
* More immutable cache headers * Cache itinerary responses Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Controller')
-rw-r--r--lib/Controller/AccountsController.php2
-rw-r--r--lib/Controller/AutoCompleteController.php3
-rw-r--r--lib/Controller/AutoConfigController.php10
-rw-r--r--lib/Controller/AvatarsController.php2
-rw-r--r--lib/Controller/ContactIntegrationController.php4
-rwxr-xr-xlib/Controller/MessagesController.php10
6 files changed, 18 insertions, 13 deletions
diff --git a/lib/Controller/AccountsController.php b/lib/Controller/AccountsController.php
index f70cf6e41..4de62fa85 100644
--- a/lib/Controller/AccountsController.php
+++ b/lib/Controller/AccountsController.php
@@ -402,6 +402,6 @@ class AccountsController extends Controller {
if ($quota === null) {
return MailJsonResponse::fail([], Http::STATUS_NOT_IMPLEMENTED);
}
- return MailJsonResponse::success($quota);
+ return MailJsonResponse::success($quota)->cacheFor(5 * 60, false, true);
}
}
diff --git a/lib/Controller/AutoCompleteController.php b/lib/Controller/AutoCompleteController.php
index 4e1c60b25..2edb7b6dc 100644
--- a/lib/Controller/AutoCompleteController.php
+++ b/lib/Controller/AutoCompleteController.php
@@ -57,6 +57,7 @@ class AutoCompleteController extends Controller {
return new JSONResponse([]);
}
- return new JSONResponse($this->service->findMatches($this->userId, $term));
+ return (new JSONResponse($this->service->findMatches($this->userId, $term)))
+ ->cacheFor(5 * 60, false, true);
}
}
diff --git a/lib/Controller/AutoConfigController.php b/lib/Controller/AutoConfigController.php
index 796f7a42a..1c2517753 100644
--- a/lib/Controller/AutoConfigController.php
+++ b/lib/Controller/AutoConfigController.php
@@ -62,20 +62,22 @@ class AutoConfigController extends Controller {
public function queryIspdb(string $email): JsonResponse {
$rfc822Address = new Horde_Mail_Rfc822_Address($email);
if (!$rfc822Address->valid) {
- return JsonResponse::fail('Invalid email address', Http::STATUS_UNPROCESSABLE_ENTITY);
+ return JsonResponse::fail('Invalid email address', Http::STATUS_UNPROCESSABLE_ENTITY)
+ ->cacheFor(60 * 60, false, true);
}
$config = $this->ispDb->query($rfc822Address->host, $rfc822Address);
- return JsonResponse::success($config);
+ return JsonResponse::success($config)->cacheFor(5 * 60, false, true);
}
public function queryMx(string $email): JsonResponse {
$rfc822Address = new Horde_Mail_Rfc822_Address($email);
if (!$rfc822Address->valid) {
- return JsonResponse::fail('Invalid email address', Http::STATUS_UNPROCESSABLE_ENTITY);
+ return JsonResponse::fail('Invalid email address', Http::STATUS_UNPROCESSABLE_ENTITY)
+ ->cacheFor(60 * 60, false, true);
}
return JsonResponse::success(
$this->mxRecord->query($rfc822Address->host),
- );
+ )->cacheFor(5 * 60, false, true);
}
public function testConnectivity(string $host, int $port): JsonResponse {
diff --git a/lib/Controller/AvatarsController.php b/lib/Controller/AvatarsController.php
index 6bcae9348..bd52d011c 100644
--- a/lib/Controller/AvatarsController.php
+++ b/lib/Controller/AvatarsController.php
@@ -73,7 +73,7 @@ class AvatarsController extends Controller {
// Debounce this a bit
// (cache for one day)
- $response->cacheFor(24 * 60 * 60);
+ $response->cacheFor(24 * 60 * 60, false, true);
return $response;
}
diff --git a/lib/Controller/ContactIntegrationController.php b/lib/Controller/ContactIntegrationController.php
index a5537ca5b..a95be9f2c 100644
--- a/lib/Controller/ContactIntegrationController.php
+++ b/lib/Controller/ContactIntegrationController.php
@@ -49,7 +49,7 @@ class ContactIntegrationController extends Controller {
* @return JSONResponse
*/
public function match(string $mail): JSONResponse {
- return new JSONResponse($this->service->findMatches($mail));
+ return (new JSONResponse($this->service->findMatches($mail)))->cacheFor(60 * 60, false, true);
}
/**
@@ -93,6 +93,6 @@ class ContactIntegrationController extends Controller {
*/
public function autoComplete(string $term): JSONResponse {
$res = $this->service->autoComplete($term);
- return new JSONResponse($res);
+ return (new JSONResponse($res))->cacheFor(60 * 60, false, true);
}
}
diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php
index a0f68fe9e..d314c7f04 100755
--- a/lib/Controller/MessagesController.php
+++ b/lib/Controller/MessagesController.php
@@ -264,7 +264,7 @@ class MessagesController extends Controller {
$response = new JSONResponse($json);
// Enable caching
- $response->cacheFor(60 * 60);
+ $response->cacheFor(60 * 60, false, true);
return $response;
}
@@ -288,7 +288,9 @@ class MessagesController extends Controller {
return new JSONResponse([], Http::STATUS_FORBIDDEN);
}
- return new JsonResponse($this->itineraryService->extract($account, $mailbox, $message->getUid()));
+ $response = new JsonResponse($this->itineraryService->extract($account, $mailbox, $message->getUid()));
+ $response->cacheFor(24 * 60 * 60, false, true);
+ return $response;
}
private function isSenderTrusted(Message $message): bool {
@@ -431,7 +433,7 @@ class MessagesController extends Controller {
]);
// Enable caching
- $response->cacheFor(60 * 60);
+ $response->cacheFor(60 * 60, false, true);
return $response;
}
@@ -524,7 +526,7 @@ class MessagesController extends Controller {
$htmlResponse->setContentSecurityPolicy($policy);
// Enable caching
- $htmlResponse->cacheFor(60 * 60);
+ $htmlResponse->cacheFor(60 * 60, false, true);
return $htmlResponse;
} catch (Exception $ex) {