-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Cris,
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? >> >> BACKGROUND: >> >> 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 g-to-recognize-new-content >> >> >> - - https://stackoverflow.com/questions/3743136/how-to-disable-tomcat-cach ing >> >> I added <Resources cachingAllowed="false" /> to the <Context> in >> TC/conf/context.xml, which solved the problem. >> >> QUESTIONS: >> >> 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". > >> CAVEATS: >> >> 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: <PostResources cachingAllowed="false" base="/base/path/to/image/files/" className="org.apache.catalina.webresources.DirResourceSet" 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 -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlu2SX0ACgkQHPApP6U8 pFiQlxAAvUP050ASoS/ZbFuEH2bY0On7RozGAZIThJUBlxKVFYOcIeKC6Vz9jB0d IUhBhA4CwXI3Pq908LDkmsV4qtvxwEGb0jhjYc31JThyBWy9Ps9RsPhApFHvt1fR Prdm5/y5PQsi1sU8bYvyA3TIgkgeX5Wh+x/XNh502eR6Y7MaIwrp58u4FzPW9BXx 0/ByD5UCnnpYm7Rhc6+aFB3YzgVrWx04DKgJCp+McjsPpUwVuPsXSG1pqe7Yjp7M EHVRDKmhlB/+UHNPJ+XC8mcFCf0giEFh7k1m9m0jMtCx2hzIe2mt5HYTWi92QtRD Qvko3s/dqtSzqUt2JZoFvG2pyabqsnGNWZmsLQfcHMJXgwRCirRz2rManlHX/qAe 0mbwUc/0wJKyV2P7vcgO9X7tBzqgqIuTbsa11+Qo9xos3/Oi3hDlmo5CdbJ3tX/l QboQnR+5nx2FAkSVfdFblR3eUGBUl8GTX055h0m1KtAw9cOCfaIvyK0Vo681Pahr +4a74tfOH+e+oU7x7pYD+2/7O7d9/1dz4NiCUQNYlMvoLTZJY1A9eDFoxSYajG4Y GfkCJD5kJAiE70lZ7J2rRJLQiA+o+OSjGdHmikYqD00IoK0jJv9nMuNOfDe9FRy7 Q2vAm1yzzkMaZcQPRBFs9RDFw4VtL47j8OpWmFeNdNah2dH4rlg= =QTsR -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org