https://issues.apache.org/bugzilla/show_bug.cgi?id=46048





--- Comment #28 from Alex Watson <alex_wat...@standardandpoors.com>  2009-04-06 
00:20:02 PST ---
I am experiencing problems with the same image caching issue, and have a few
suggestions for an alternate approach to resolving this issue. Unfortunately
our base URI does not change so the patch included already for this defect does
not help us here.

We have a FOP-based webserver, that generates PDF files with embedded images.
We also use a URIResolver to intercept requests for images and map them onto
different resources. Many of the images are static (logos etc), but some of
these images change infrequently (perhaps once a week).

I discovered this problem when an image was missing on our webserver, but
replacing the image did not fix the PDF (the absence of the image was cached as
well). Similarly, deleting or changing an image did not alter the PDF.

I am concerned about performance and scalability, so I would rather not create
a new FopFactory for each request. The workaround to call
fopFactory.getImageManager().getCache().clearCache() is brute-force - this will
flush images for all threads and reports (even if another thread is rendering a
PDF at the time).

I think the ideal behaviour is to allow image caching to be optionally
configurable on the session/run rather than globally on the FopFactory.

My suggestion is to allow the FOUserAgent to be (optionally) configured with
its own ImageManager. The FOUserAgent constructor would default to the
ImageManager from the FopFactory (to preserve existing behaviour by default).

The externalGraphic and PDFRenderer classes would change from
        FOUserAgent userAgent = getUserAgent();
        ImageManager manager = userAgent.getFactory().getImageManager();
to
        ImageManager manager = userAgent.getImageManager();

To use session based image caching would simply require a new method to be
invoked on the FOUserAgent to create its own ImageManager eg. FOUserAgent
enableSessionCaching() {this.imageManager = new ImageManager(factory); }.

An additional benefit is that session based images would be cleaned up much
sooner (helping with our monitoring of free memory within the app).

Another useful enhancement would allow the ImageCache to be configurable to
exclude some URI patterns from its cache (perhaps by extending
ImageCacheListener). This could enable a session based cache to cache some
images (based on uri) and then fall through to the global cache for other
images.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to