JSF libraries for static content - or regular static files - performance?

We have two ways in which we can serve elements such as images, javascript, css.

  • Static scope, for example, "/images/foo.png"
  • JSF library that displays something like "/javax.faces.library/foo.png?ln=images"

The latter is similar to how everything happens in JSF. It is easy to do. There is a lot of support.

The first allows interesting tricks in a situation where performance is calculated. We can organize our server so as not to transmit / images to the servlet engine, but instead use something faster. In fairness, I should say that I do not know anyone who uses our software that did this, or how much it cost to have something like Tomcat or JBoss, static content on top of something native, such as Apache, and how much it costs from the cost of business logic which also continues to provide the application.

We hope that in both cases the images will be served for a long time so that the browser can cache them. I note that the JSF version has a part of the query string, so we hope that the browser does not decide that it knows better and refuses to cache. We need to look at some traces to see what happens.

So what to do? JSF libraries? Use especially support in things like h: outputScript and h: outputStylesheet? Or a site image area?

Thanks - Richard

+6
source share
2 answers

For performance reasons, I found myself better with a custom solution in which jsf did NOT manage the dependencies of my page. Having your own dependency resolution mechanism with a kind of custom servlet “resource management” gives you more flexibility as to what you can do when each resource is requested.

Some of the benefits of this,

  • Adding caching headers to suit your requirements
  • The ability to serve combined resources instead of using one resource at a time. Therefore, if you create resource URLs such as " http://server.com/app/resources/one,two.js , you can serve both one.js and two.js files in the same request by concatenating them in memory.
  • The ability to use the cache invalidation strategy by simply changing the request parameters for images. eg. http://server.com/app/resources/images/apple.jpg?version=1 , where the "version" may be the version of your application.
  • Maintain your own static resource directory structure and should not strictly rely on jsf resource directory structure.

Alternatively, you can also delegate all this to another application or third party to make it all better.

+1
source

There are several things you can do to improve the performance of your screens and static content / libraries / java scripts.

  • The GZIP filter will significantly reduce boot time. It compresses the contents of the page when transferred to the client browser. See fooobar.com/questions/9608 / ...
  • You can optionally implement cacheFilter to ensure the performance of your screens match the JavaScript-based user interface. This will cache the static content of your screen, such as icons, images, style sheets, javascripts, etc. You can control what needs to be cached and what to exclude. See fooobar.com/questions/8784 / ...
  • For client-side user interface components, you can use Primefaces , which is a jQuery-based user interface.

How to check if gzip and cache work on my screen

To find out if your content is already in use in gzip and cache in the Google Chrome browser - right-click on the screen → check → click the network tab → refresh the screen. Click on images, icons, style sheets and see if you see the following in the response header

Cache-Control:max-age=2592000 if item status is 304 (from cache)

Content-Encoding:gzip if item status is 200

0
source

Source: https://habr.com/ru/post/899251/


All Articles