简体   繁体   中英

Does JSF cache the state of each component in between the two requests?

" In JSF, the state of the each component is stored in between the requests " - This means that the data is cached(!?) at the application servers thus the servers will now have larger memory requirements(!?).

But I guess we can also make the state requestScoped , so this will not cache the data at application servers during the two requests, right? Am I getting it correctly ?

[My application contains blog posts of users which are large text blobs which would be very costly to cache. But yes there is some data that requires caching! ]

The sentence you mention here is about JSF state saving, which saves the state of the component tree. By default, this is done on the server... but you could also do it on the client, to save some mememory. See this: http://wiki.glassfish.java.net/Wiki.jsp?page=JavaServerFacesRI#section-JavaServerFacesRI-WhatAreTheDifferencesBetweenServerAndClientSideStateSavingAndWhatAreTheBenefitsDrawbacksOfEach

Backing beans scope is something else. You can make backing beans session / request / view scoped (or even use another or custom scope). This will have an impact on server memory usage. However, if you do it correctly and don't have big data requirements, you could manage that. For example, you could store as little as possible and reload your data regularly (from db, ...).

All this doesn't mean your data is cached (at least, not the data coming from persistent storage). This is up to you.

So, memory requirements are something to keep in eye. The basic setup for a full-blown Java EE server is typically more than for a php application on an apache server... But, done correctly, making it faster / better / more scalable (cpu / mem) could be simpler to achieve.

In the last year I had to create two JSF applications. If I remember correctly you could cache your data in your Backing Bean so that you do not hit your database to retrieve your blog contents with every refresh.

Pretty much JSF has a very strong server-client presence. It is pratically impossible to imagine that JSF will only run on the client like GWT.

Are you using IceFaces or any other JSF implementation like RichFaces?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM