From b7f74572b09764be0fbe7fcd8003626d1bc6d8c5 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 11 Oct 2024 16:24:35 +1100 Subject: [PATCH] Only check if max_datasets is being exceeded if it's not set to 0 --- datacube_ows/resource_limits.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/datacube_ows/resource_limits.py b/datacube_ows/resource_limits.py index 5eefea635..51103059c 100644 --- a/datacube_ows/resource_limits.py +++ b/datacube_ows/resource_limits.py @@ -182,7 +182,9 @@ def cache_headers(self, n_datasets: int) -> Mapping[str, str]: if not self.use_caching: return {} assert n_datasets >= 0 - if n_datasets == 0 or n_datasets > self.max_datasets: + # If there are no datasets, don't cache. But if the max_datasets isn't 0, check + # we're not exceeding it, and in that case, don't cache either. + if n_datasets == 0 or (self.max_datasets > 0 and n_datasets > self.max_datasets): return cache_control_headers(0) rule = None for r in self.rules: