Skip to content

fix: add proper cache control headers for all public endpoints#1863

Open
netomi wants to merge 3 commits into
mainfrom
support-caching-extension-json
Open

fix: add proper cache control headers for all public endpoints#1863
netomi wants to merge 3 commits into
mainfrom
support-caching-extension-json

Conversation

@netomi
Copy link
Copy Markdown
Contributor

@netomi netomi commented May 22, 2026

Previously, some endpoints did not include proper or inconsistent cache control headers.

This leads to the situation that responses can not be cached on the CDN level as it honors the cache control headers returned by the application.

This PR sets the cache control headers consistently for all public API endpoints:

  • set a consistent max-age for all endpoints which did not have it already
  • set max-age of 10m also for 404 responses and add mustRevalidate in such cases
  • the VSCode adapter api mostly just redirects to the regular api, add proper cache control there as well to let the CDN / reverse proxy properly cache the redirect to avoid duplicate requests

Currently for the majority of the endpoints we set 10min as max-age which is reasonable (changes will be reflected after max 10 min afaict), but this should be configurable.

@netomi netomi requested a review from gnugomez May 22, 2026 07:06
Comment thread server/src/main/java/org/eclipse/openvsx/adapter/VSCodeAPI.java Fixed
Comment thread server/src/main/java/org/eclipse/openvsx/adapter/VSCodeAPI.java Fixed
Comment on lines +213 to +216
return ResponseEntity.status(HttpStatus.FOUND)
.cacheControl(CacheControl.maxAge(1, TimeUnit.DAYS).cachePublic())
.location(URI.create(itemUrl))
.build();
Comment on lines +272 to +275
return ResponseEntity.status(HttpStatus.FOUND)
.cacheControl(CacheControl.maxAge(1, TimeUnit.DAYS).cachePublic())
.location(URI.create(downloadUrl))
.build();
Copy link
Copy Markdown
Member

@gnugomez gnugomez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why instead of setting them manually don't you add a global config in the SecurityConfig#filterChain?

@netomi
Copy link
Copy Markdown
Contributor Author

netomi commented May 22, 2026

as we do not want the same cache control for all endpoints, they at least slightly differ. Till I have a better way to express that I just do it consistently for all endpoints, as some where omitted so far, and 404 did not have any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants