There are several servlets; when processing a request, everyone reads the same file from disk. Those. with each request, the file is read again.

Is it possible to cache this file?

So that it is read from disk only 1 time (when processing the first request or when starting the server), and later it was taken from RAM.

  • one
    Attempting to cache something without making performance measurements is a big mistake. I hope you made them and are 100% sure that the file system is definitely the bottleneck of your application. Disk storage technologies and access methods have been refined for more than a decade, and for most tasks, access speeds are not critical in terms of performance. Regarding caching - much is cached without your direct participation, the disk controller and the operating system. You should not create another bike ... - bobzer
  • @AlexeyKholodkov Servlets in the same war file or in different? What do you have - Tomcat or TomEE? - user194374
  • @kff Tomcat 8.0.35. I don't use war files, servlets are in the same webapp - Alexey Kholodkov
  • Not sure, but it probably won't work. I know a way to make a global object for a server that will live from start to restart, but it requires EJB support. And for this you need a minimum of TomEE, and better JBoss / WildFly (you can also use GlassFish, but it is a braking one). - user194374
  • Judging by the question, do you happen to have a config there? Just then this is not called caching, but a completely different use case. - enzo

0