Hash: SHA256


On 10/4/18 09:54, Mark Thomas wrote:
> On 04/10/18 14:41, Berneburg, Cris J. - US wrote:
>> Hi Folks
>> Anyone have advice on, experience with, or info about setting
>> cachingAllowed=false?
>> Our customer is suddenly getting a JasperException in production.
>> To solve, we're planning to upgrade Tomcat to 8.5.x.  In our
>> testing of TC 8.5.32 on Java 8u181, report output Excel files
>> won't load (immediately).  An error is displayed to the user.
>> These Stack Overflow topics below point to a cachingAllowed
>> setting:
>> -
>> https://stackoverflow.com/questions/44852505/tomcat-8-5-takes-too-lon
- - https://stackoverflow.com/questions/3743136/how-to-disable-tomcat-cach
>> I added <Resources cachingAllowed="false" /> to the <Context> in
>> TC/conf/context.xml, which solved the problem.
>> 1. What are the ramifications of disabling the cache?  IOW, what
>> are the potential side-effects?
> The cache keeps the contents of static files in memory to improve 
> performance. In theory - the more of your requests that can be
> served from memory, the faster the response time. The side effect
> is a slower response time. How much actual difference this feature
> makes will depend on how much static content there is in your app,
> how frequently it is requested and how frequently it is changed.
>> 2. Is there a "better" way to specify the setting?
> Maybe. The change you made applied that setting to ALL web
> applications in that Tomcat instance. If you only wanted to apply
> it to "/foo" then you would create: 
> $CATALINA_BASE/conf/<engine-name/<host-name>/foo.xml and add
> content something like: <Context> <Resources cachingAllowed="false"
> /> </Context>
>> 3. Is there a "better" way to solve the problem?
> For a given value of "better"...
> What is happening is that: - "something 1" requests the file - the
> file is not found and the cache records this - "something 2"
> creates the file - "something 3" requests the newly created file -
> the cache is still valid so the not found' response is returned -
> time passes, 'not found' cache response expires - "something 4"
> requests the newly created file which is now returned
> something 1/2/3/4 - may all be different - some may be the same -
> may be Tomcat or application code
> What you'd need to figure out is what is "something 1" and what
> triggers it before "something 2". With that information, you should
> be able to refactor the app so "something 1" doesn't happen or
> happens after "something 2".
>> a. This is a low-volume application.  Little traffic and few
>> users.
>> b. Seeing as we're addressing production, we would like to
>> implement a rapid solution.  Don't want to refactor the
>> application, which would take more time.
>> THANKS: for your time and assistance!
> Given the caveats, you solution looks to be the best (assuming 
> performance is acceptable).

Long ago, we added something similar to what you are talking about.
Basically, it was a file-upload capability for images. We waffled
about whether to just map the /uploaded-images/ URL space directly to
the disk and have DefaultServlet serve the bytes or to write our own
servlet to do the work.

We opted to write our own (very basic) servlet to do the work because
of our concerns over caching by DefaultServlet / Resources. If you
want complete control, you have to take responsibility for that
complete control.

Re-reading the documentation for <Resources> (specifically,
<PostResources>), it seems that:

        webAppMount="/uploaded-images/" />

... might do the trick, and it would only disable caching for that
portion of the disk.

Perhaps this would be a better solution, because it only disabled
caching for a *portion* of the requests you'll be handling.

- -chris
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/


To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to