Response Cache-control header, based on requests made. #32071
-
Hello. During processing of a quarkus request, there are quarkus services that make other http requests to other servers. These responses return 'Cache-Control' headers. I want to set a quarkus response cache-control header, based on the received responses from the other servers - for example, if a server responds with JSON data, with a CacheControl: max-age= 5678, and my quarkus app has built a page based on that data, then I want my quarkus app to also include Cache-Control:max-age=5678 with the page. The problem is that things are happening reactively, so the requests/responses from other servers is happening in another thread. The Qute template gets a CompletableFuture, and works fine. BUT, I need something to trigger, once the qute templates have fully being populated, but before the response has returned back to the user. Help! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
/cc @gwenneg (cache) |
Beta Was this translation helpful? Give feedback.
-
@geoand Do you know who could answer that question? |
Beta Was this translation helpful? Give feedback.
-
That would be me :) I can't say I understand the relevance between the Mind showing some example code (just pseudo-code is fine) showing what exactly you want to do? |
Beta Was this translation helpful? Give feedback.
-
I think I have a solution that fits my usecase: If I do: rather than returning the weatherPageInstance, this forces weatherPageInstance to fully render, which means all cache-controls, returned by requests for data to build the weatherPageInstance. will have resolved. Which means I can set the cache-control header in my controller. :-) Not sure if this is the right, or best way, but it works for me. |
Beta Was this translation helpful? Give feedback.
-
If the WeatherService returns a |
Beta Was this translation helpful? Give feedback.
I think I have a solution that fits my usecase:
If I do:
String responseHTML = weatherPageInstance.render();
rather than returning the weatherPageInstance, this forces weatherPageInstance to fully render, which means all cache-controls, returned by requests for data to build the weatherPageInstance. will have resolved.
Which means I can set the cache-control header in my controller.
:-)
Not sure if this is the right, or best way, but it works for me.