Search code examples
wildfly-8

Static content delivery vs dynamic in WildFly


My application ear is bundled with static resources like js, css, images, etc and was serving js files at URI app/scripts. These requests were passing through filters in the application. Now I configured WildFly to serve static contents like images, js and css. It is served at path app/scripts for js. Since both have same URI which one will be working now? It looks like static content is getting precedence because I noticed that now request are not passing through filters. Which method is better option to improve performance?


Solution

  • Hi Make your static contents as a separate deployment. And Create a folder named "MyContents.war" in deployment folder of your Wildfly and keep all your scripts, css what ever inside that folder, add the following settings in your standalone.xml file inside <server> tag.

    <deployments>
            <deployment name="MyContents.war" runtime-name="MyContents.war">
                <fs-archive path="deployments\MyContents.war" relative-to="jboss.server.base.dir"/>
            </deployment>
     </deployments>
    

    Now to access any resource like a script file for example scripts.js

      http://<yourhost>:<port>/MyContents/scripts/scripts.js 
    

    Hope this helpful for you.