From 078d4c0b61421c255a0b7c3f5fd9b4729fea5e3d Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Tue, 21 Jul 2020 09:14:36 +0200 Subject: [PATCH] Add cache headers for packages.json --- src/Controller/ProxyController.php | 7 +++++-- src/Controller/RepoController.php | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Controller/ProxyController.php b/src/Controller/ProxyController.php index 6774bb6f..6125c427 100644 --- a/src/Controller/ProxyController.php +++ b/src/Controller/ProxyController.php @@ -34,7 +34,7 @@ public function __construct(ProxyRegister $register) */ public function packages(): JsonResponse { - return new JsonResponse([ + return (new JsonResponse([ 'notify-batch' => $this->generateUrl('package_downloads', [], RouterInterface::ABSOLUTE_URL), 'providers-url' => '/p/%package%$%hash%.json', 'metadata-url' => '/p2/%package%.json', @@ -46,7 +46,10 @@ public function packages(): JsonResponse ], ], 'providers-lazy-url' => '/p/%package%', - ]); + ])) + ->setPublic() + ->setTtl(86400) + ; } /** diff --git a/src/Controller/RepoController.php b/src/Controller/RepoController.php index f729ceba..02555ef9 100644 --- a/src/Controller/RepoController.php +++ b/src/Controller/RepoController.php @@ -32,6 +32,7 @@ public function __construct(PackageQuery $packageQuery, PackageManager $packageM /** * @Route("/packages.json", host="{organization}.repo.{domain}", name="repo_packages", methods={"GET"}, defaults={"domain":"%domain%"}, requirements={"domain"="%domain%"}) + * @Cache(public=false) */ public function packages(Organization $organization): JsonResponse { @@ -117,6 +118,7 @@ public function downloads(Request $request, Organization $organization): JsonRes * methods={"GET"}, * defaults={"domain":"%domain%"}, * requirements={"domain"="%domain%","package"="%package_name_pattern%"}) + * @Cache(public=false) */ public function providerV2(Organization $organization, string $package): JsonResponse {