>>  More precisely then, JARs and classes from WEB-INF/lib / WEB-INF/classes won't be cached but non-class resources in those locations will be.

This app, the cache starts to complain at approx 18mb.

If I calculate the size roughly (right click properties) of all the target/class folders = 21.97mb, and the target/classes/com folders = 1.0648mb.

So the calculated size would be 20.9129 ie 21mb.

...I guess using post resources this way was not in the initial scope, but it works great (way better than the previous way).

Thanks Greg

On 07/11/2023 09:12, Mark Thomas wrote:
On 07/11/2023 08:05, Greg Huber wrote:
 >> The "i.e. everything NOT under WEB-INF/lib or WEB-INF/classes" is irrespective of which resource collection it is in. So JARs >> from PostResources won't be cached.

OK sorry missed the not.

Although I am mapping in post resources to a maven project which has a resources folder that ends up in the target/classes folder.

Ah. More precisely then, JARs and classes from WEB-INF/lib / WEB-INF/classes won't be cached but non-class resources in those locations will be.

Mark

<PostResources
base="/home/devuser/git/mavenproject/myplugin/target/classes"
className="org.apache.catalina.webresources.DirResourceSet"
             webAppMount="/WEB-INF/classes" />

ie

/home/devuser/git/mavenproject/myplugin/src/main/resources/template/..

WARNING: Unable to add the resource at [/WEB-INF/classes/template/js/jstree/jquery.hotkeys.min.js] to the cache for web application [/myapp] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache Nov 07, 2023 6:22:52 AM org.apache.catalina.webresources.Cache getResource


Checking the logs, it only complains about /WEB-INF/classes/

I will test and calculate the size of all the target/classes folder which are mapped under /WEB-INF/classes in post resources.

Cheers Greg

On 06/11/2023 12:19, Mark Thomas wrote:

On 06/11/2023 10:57, Greg Huber wrote:
 >> The maximum useful size will be the total size of static resources (i.e. everything NOT under WEB-INF/lib or WEB-INF/classes).

Since I have nothing in either of these, its all mapped in the PostResources,  I can just calculate the size of the jars, and add a bit for luck.  (ie 85mb +5mb).🙂

The "i.e. everything NOT under WEB-INF/lib or WEB-INF/classes" is irrespective of which resource collection it is in. So JARs from PostResources won't be cached.

Mark



Thanks

On 06/11/2023 09:43, Mark Thomas wrote:
On 05/11/2023 17:23, Greg Huber wrote:
Thanks Mark and Chris.

<PostResources
base="/home/devuser/git/myproject/target/classes"
className="org.apache.catalina.webresources.DirResourceSet"
              webAppMount="/WEB-INF/classes" />

I have not noticed any slowness yet.

There are alot of jars (approx 160), but the target/classes folder are my app's classes that I am working on.  These can change (ie not static), so
may be better to switch it off.

Is there anyway to calculate the size needed for the cache setting?

The maximum useful size will be the total size of static resources (i.e. everything NOT under WEB-INF/lib or WEB-INF/classes).

The right size is going to be a trade-off between the cost of the memory for the cache and the benefits the cache brings. Those benefits are going to be application (and hardware) dependent.

Mark



Thanks Greg


On Sun, 5 Nov 2023 at 15:31, Christopher Schultz <
ch...@christopherschultz.net> wrote:

Greg and Mark,

On 11/5/23 09:31, Mark Thomas wrote:
On 05/11/2023 10:18, Greg Huber wrote:
OK thanks, the docs mention "static resource cache" but I could not
find info on what it actually is.

It caches the content of static resources in memory and uses that rather
than accessing disk.

I am loading maven jars and /target/classes.

eg:

<PostResources
base="/home/devuser/git/myproject/tools/META-INF"
className="org.apache.catalina.webresources.DirResourceSet"
webAppMount="/WEB-INF/classes/META-INF" />

<PostResources
base="/home/devuser/git/myproject/target/classes"
className="org.apache.catalina.webresources.DirResourceSet"
              webAppMount="/WEB-INF/classes" />

<PostResources

base="/home/devuser/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar"
className="org.apache.catalina.webresources.FileResourceSet"
webAppMount="/WEB-INF/lib/commons-logging-1.2.jar" />


As its purely for development guess it makes no difference?

I doubt you'll notice if you disable it.

+1

Since you are using JAR files, the caching won't matter once the classes
themselves are loaded-into memory. So you may observe some slowness
early in the lifetime of the web application after deployment, but at long as your code, etc. isn't trying to re-scan JAR files all the time,
etc. then you should be fine.

-chris

On 05/11/2023 10:02, Mark Thomas wrote:
On 04/11/2023 11:03, Greg Huber wrote:
Hello,

I am using the <Resources> and <PostResources> to run tomcat for debugging my app (and it is pretty awesome). I am getting the cache warning limit, as it is 10mb, what effect would it have if I turned
off the cache ie cachingAllowed="false" rather than having to
increase the limit all the time?

This is one of those "it depends" questions. There are lots of
factors that will influence how effective the cache is. You could try and reason what the impact would be but you will likely get a more accurate answer, faster by just trying it and measuring the impact.

Mark

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


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


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




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


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


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


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

Reply via email to