Federico Alvarez
Federico Alvarez

Reputation: 1519

Tomcat 8.5 takes too long to recognize new content

I have the following problem, I write an Excel file in C:\Tomcat85\webapps\MyWebApp\Excel\myExcel.xls.

As soon as my Java application finishes writing the file, it performs a download for the user to work with it. This gives a nasty 404 error.

If I wait a few seconds and reload the page it downloads all right (or adding a five second sleep in java, it works the same).

So, what I conclude is that Tomcat is taking 5 seconds to recognize that this new excel file exists and just then is able to serve it.

Is there anyway to make Tomcat perform this task faster? Maybe using some configuration in web.xml to treat that "/Excel/" folder differently.

Windows 10 64bits, Tomcat 8.5, Java 7 (could try java8 but I dont think it will make a difference).

Some code:

new ExcelExport(remoteHandle, context).execute( outFileName, outMessage);
// Thread.sleep(5000);
httpContext.wjLoc = formatLink(outFileName);

The wiriting is working fine, as I see it ready and writable in File Explorer, but if I try to open it by URL I get the same 404.

Upvotes: 1

Views: 795

Answers (1)

Italo Borssatto
Italo Borssatto

Reputation: 15689

Resources are cached by default. The amount of time in milliseconds between the revalidation of cache entries is defined by the cacheTtl parameter, referenced in this documentation. By default its value is 5 seconds.

If you want to disable the cache, just set the cachingAllowed to false.

Upvotes: 2

Related Questions