Intercepting outgoing servlet HTTP requests

I am working on a school project in which I request and receive fairly large XML documents from a central server. This was good at the beginning, as I rarely made these requests (HTTP GET), but as the project progressed, I came up with more things related to this data, and now I have servlets requesting 3 or 4 XML documents, each of which it has a separate GET request, which causes an increase in page generation time of 25 seconds.

It is impossible to change the way the data is presented, nor the way in which it was requested, since I have a rather large code base, and this is not the way it was possible.

Is there any reasonable way to listen when my servlets execute these GET requests, intercept them and possibly supply them with a local cached version? Data is not THAT volatile, so no live data is needed.

So far, I have not been able to find information on listening to outgoing requests made by Tomcat ...

+3
source share
3 answers

I think a lot will depend on your cache hit ratio. If the same 3-4 documents are requested on a regular basis (or a small group of documents), a local caching proxy server (for example, Squid) may be possible. Java can configure to use a proxy server for HTTP requests.

+1
source

, HttpFilter. . , ; HTTP- .

0

I ended up using ContextListener to load most of the data at startup in addition to the "expiration date" in the servlet context attributes. This leads to some slow starts (9 GetRequests to the central server!), But significantly reduces page load time.

0
source

Source: https://habr.com/ru/post/1795729/


All Articles