We have two ways we can serve items like images, javascript, css.
The latter seems the way that things go in JSF. It's easy to do. There's a lot of support for it.
The former allows interesting tricks in a situation where performance counts. We can arrange our server to not pass /images to the servlet engine but use something faster instead. To be fair I don't know of anyone using our software who has done this, or how much a cost having something like Tomcat or JBoss serve static content over something native such as Apache and how much this is against the cost of the business logic that is also going on to provide the application itself.
We hope that in both cases the images will be served with a long time to live so the browser can cache them. I note the JSF version has a query string part, so hope that a browser doesn't decide it knows better and refuses to cache. We'll have to look at some traces to see what's happening.
So which to do? JSF libraries? Take advantage especially of support in things like the h:outputScript and h:outputStylesheet controls? Or an images area of the site?
Thanks - Richard
In a "static" web server, the incoming URL is mapped to a file path on a local disk, and the response is created based on the contents of that file. In a "dynamic" web server, the incoming URL is processed in some other way, and the response is generated according to more complicated logic.
To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express. The root argument specifies the root directory from which to serve static assets. For more information on the options argument, see express.static.
Web server is useful or fitted for static content. Whereas application server is fitted for dynamic content.
For performance reasons, I found myself better off using a custom solution where jsf did NOT manage my page dependencies. Having your own dependency resolution mechanism via some sort of custom "resource management" servlet gives you a lot of flexibility with what you can do when each resource is requested
Some of the advantages of doing so,
Alternatively, you could also delegate all of these to some other application or third party to do all of these better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With