Feature/8994 cache control - #339
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds configurable HTTP Cache-Control headers for an exact-match GET request (path + query params) to support CloudFront caching, updates configuration binding to a new OgcApiProperties record, and adjusts test infrastructure/dependencies (Elasticsearch trial license during tests, stacmodel bump).
Changes:
- Introduce
HttpCacheControlFilterandogcapi.http-cacheconfiguration mappings to setCache-Controlonly for exact request matches. - Add
OgcApiProperties(ogcapi.*) and switch the admin “explain” toggle to use configuration properties instead of@Value. - Enable Elasticsearch trial licensing in Testcontainers-based tests; bump
stacmodelto0.0.66.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| server/src/main/java/au/org/aodn/ogcapi/server/core/http/HttpCacheControlFilter.java | New servlet filter that applies Cache-Control for configured exact-match GET requests. |
| server/src/main/java/au/org/aodn/ogcapi/server/core/configuration/OgcApiProperties.java | New @ConfigurationProperties record for ogcapi.debug and ogcapi.http-cache. |
| server/src/main/resources/application.yaml | Adds ogcapi.http-cache configuration mapping for /api/v1/ogc/collections. |
| server/src/main/java/au/org/aodn/ogcapi/server/core/configuration/Config.java | Registers OgcApiProperties in @EnableConfigurationProperties. |
| server/src/main/java/au/org/aodn/ogcapi/server/common/RestAdminApi.java | Uses OgcApiProperties.debug().elasticsearchExplainEnabled() gate for explain endpoints. |
| server/src/main/java/au/org/aodn/ogcapi/server/common/RestAdminService.java | Removes @Value-based explain toggle plumbing. |
| server/src/test/java/au/org/aodn/ogcapi/server/core/http/HttpCacheControlFilterTest.java | New unit tests validating exact-match cache header behavior. |
| server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java | Adds integration test asserting Cache-Control presence on the configured query. |
| server/src/test/java/au/org/aodn/ogcapi/server/core/configuration/ElasticSearchTestConfig.java | Starts Elasticsearch trial license for tests (needed for licensed semantic features). |
| server/src/main/java/au/org/aodn/ogcapi/server/core/configuration/CustomWebMvcConfigurer.java | Minor formatting-only change. |
| pom.xml | Bumps managed stacmodel version to 0.0.66. |
| server/pom.xml | Removes a duplicated jackson-databind-nullable dependency entry. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+43
to
+55
| OgcApiProperties.HttpCache httpCache = ogcApiProperties.httpCache(); | ||
| if (httpCache == null || !httpCache.enabled() || (request != null && !HttpMethod.GET.matches(request.getMethod()))) { | ||
| if (filterChain != null) { | ||
| filterChain.doFilter(request, response); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| if (filterChain != null) { | ||
| CacheControlResponseWrapper wrapped = new CacheControlResponseWrapper(request, response, httpCache); | ||
| filterChain.doFilter(request, wrapped); | ||
| wrapped.applyIfEligible(); | ||
| } |
Comment on lines
+10
to
+17
| public record OgcApiProperties( | ||
| @DefaultValue Debug debug, | ||
| @DefaultValue HttpCache httpCache | ||
| ) { | ||
| public record Debug( | ||
| @DefaultValue("false") boolean elasticsearchExplainEnabled | ||
| ) { | ||
| } |
Comment on lines
+808
to
+811
| /** | ||
| * A config set for this particular api call, we need to set the cache control header to signal cloud-front caching | ||
| * @throws IOException Not expected | ||
| */ |
| "5c418118-2581-4936-b6fd-d6bedfe74f62.json", | ||
| "19da2ce7-138f-4427-89de-a50c724f5f54.json", | ||
| "516811d7-cd1e-207a-e0440003ba8c79dd.json", | ||
| "35234913-aa3c-48ec-b9a4-77f822f66ef8.json" // This one have cloud optimized index, that is assets.summary value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.