I am using 2 modules in my java application which downloads the same web page.
So in effect the site is downloaded twice.
In order to avoid this , is there some caching layer i can attach , so that only 1 copy of the site is actually downloaded.
I would love to see the caching at Java side , if not possible at a later level like some web caching proxy or something
If the two ‘modules’ are in the same jvm and thus can access eachothers memory, try a singleton based ‘cache’. I tend to use a HtmlSnippit cache for caching much repeated HTML snippits with great success:
Now, the
getSnippit()andputSnippit()methods will probably need to besynchronizedsomehow for thread safety, but that’s another discussion (argument?) altogether 🙂(Example should run out of the box.)