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?
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.
Related
I have a Vapor server API running in Heroku supporting an iOS app. I want to create a simple landing page for my app and I would like to host it in my existing Vapor server. How could I do that?
Vapor actually has a built-in middleware that makes this very easy. First, make sure you have a Public directory at the root of your Vapor project. Then you can put your static HTML page in there, along with any CSS and JS files it might rely on.
Next, you just need to add FileMiddleware to your application's middleware (docs):
let file = FileMiddleware(publicDirectory: app.directory.publicDirectory)
app.middleware.use(file)
Now you can access any of the files in your Public directory using their relative directory path as the path in the URL to your app. For example, if you have a static directory in your Public directory, and put a home.html file in it, you request the page by going to http://localhost:8080/static/home.html in your browser.
I'm using create-react-app and in prod I'd like to serve the JS and CSS and other static assets on s3, but serve the index.html file from another location. However, the URLs in the built files are all relative paths.
Is there a way (without ejecting) to use absolute URLs in the production build?
Apparently this is achievable with the PUBLIC_URL environment variable. I was under the impression this variable was intended to be used if the React app would be living in a sub-directory, in order to fix client side routing. However, by adding:
PUBLIC_URL=https://<my-s3-bucket_url>
The URLs in all files become absolute URLs instead of relative URLs.
My ASP.NET MVC project's root directory contains some typical static files, like robots.txt, manifest.json, browserconfig.xml, etc. If I'm not mistaken, each of these examples I listed should be able to be served with no involvement from MVC via GET requests to the root directory (i.e. mysite.com/manifest.json — if that's not true, please let me know).
I know from this answer that I can configure this behavior per file type in the Web.config. My question is, what if there are other .json files in my root directory that I don't want to serve, like compilerconfig.json or bundleconfig.json (both files generated by IDE tools)? What's the best way for the application to be able to serve some files of type X, but not others?
You can always ignore them via routes:
routes.IgnoreRoute("{somefilename}.json");
Another alternative would be to move the files you don't want to be served to another folder and add a web.config file to it to manage what gets served (or doesn't).
I am sure there are other ways. Modules come to mind...
I need your help on below.
I have JSF2.0 application which runs on WAS8.5. I want to separate the static and dynamic contents as we want to use WAS server only for dynamic contents and IHS to server static contents for my application. My current architecture and design as follows:
Marked file serving flag as false in ibm-web-ext.xml file (IBM config file to say whether WAS to be served static content or Not).
We’ve used core JSF2.0 tages (h:outputStylesheet, h:outputScript and h:graphicImage) and also traditional html tags some places (link, script and img) to load static contents.
My understanding/Observation is,
1. When we load static contents using JSF2.0 components (styles using h:outputStylesheet component, java scripts using h:outputScript and images using h:graphicImage), all static contents will be served by WAS server as FacesServlet is responsible for reading the component and loading the resources accordingly. According to the JSF2.0 guidelines&standard, we should use JSF tags to load the resources like js, css and images.
2. When we load static contents using html tags, all the static contents served by webserver ie IHS
Now my question is,
My application is internet channel application where we want to serve the possible as quickly as possible. Technically, I want to use Core JSF tags wherever possible and use the WAS server to serve only dynamic contents to reduce the load.
Please advice me options to meet my requirement.
Thanks,
Nanjundan Chinnasamy
We have made the following code changes to achieve our requirement.
To server all images by IHS,
Use native JSF2.0 tag with value attribute like below.
This will generate the html source like below
We used the traditional html tags (used in JSF1.X) versions to load css and java script files like below
If we use h:outputScript and h:outputStylesheet tags available in JSF2.0, we have a name attribute which marked as mandatory. We unable to make it static reference using value attribute alone. We don’t have much documentation at MyFaces site to give references to you. Mean time, you can have a look the following:
https://myfaces.apache.org/core20/myfaces-impl/tagdoc/h_outputScript.html
https://myfaces.apache.org/core20/myfaces-impl/tagdoc/h_outputStylesheet.html
If you any other suggestion/comments, please do let me know. We will revert you with an update.
Thanks,
Nanjundan Chinnasamy
Lift Framework seems to need a lot of very specific configuration to serve static files. This is pretty tough if you want to use something like jQueryUI with Lift. Can anyone point me to a Lift project that has all the configuration necessary to use jQueryUI?
No extra configuration is needed to use JQuery UI with Lift. Simply put the JS files into the webapp directory like you would with any other static resource. The servlet container will serve that exactly like it would for any other WAR application.
You only need to resource server stuff if you want to serve files from deep in your class path (like from another JAR for example)