如何使 myfaces-impl 在文件更改时刷新?
Facelets servlet 有一个 init-param facelets.REFRESH_PERIOD
。然而,将其设置为特定值是没有意义的。当它太小时,比如10秒,缓存就会超时太快。如果不是那么小,比如 5 分钟,那么当对 xhtml 文件进行小的更改时,我必须频繁地重新启动 Web 服务器。 10 到 300 秒之间的值可能更好,但绝不是最好的。
我正在使用 Apache myfaces-impl,我对 Sun JSF RI 不太了解。 (Sun JSF RI 在我们的项目中不起作用)所以,我不知道这个问题是否特定于 Apache Myfaces?
好吧,我可以让 myfaces-impl 刷新那些已更改的文件,而不是指定 REFRESH_PERIOD 吗?
(我想 myfaces-impl 可能无法获取文件的上次修改时间,因为它将文件解析为 URL,而 URL 没有上次修改时间属性,是吗?或者我应该修补myfaces-impl 我自己?)
There is an init-param facelets.REFRESH_PERIOD
for the Facelets servlet. However, it's senseless to set it to a specific value. When it's too small, say 10 seconds, the cache will be timeout too fast. When it's not so small, say 5 minutes, then I have to restart the web server frequently when a small change is made to the xhtml file. A value between 10 and 300 seconds maybe better, but never the best.
I'm using Apache myfaces-impl, I don't know much about Sun JSF RI. (Sun JSF RI doesn't work in our project) So, I don't know if this question is specific to Apache Myfaces?
Well, rather then specify the REFRESH_PERIOD
, can I just let myfaces-impl refresh those files which were changed?
(I guess maybe myfaces-impl doesn't get the file last-modified-time, because it resolves files as URLs, and a URL doesn't have a last-modified-time property, yeh? Or should I have to patch on myfaces-impl myself? )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 MyFaces Web Config Params
javax.faces.FACELETS_REFRESH_PERIOD 是标准参数姓名。
此参数在开发时用于重建视图,因此您可以更改页面并即时检查更改。您不需要在生产中进行设置。尝试将其设置为 -1 并禁用它。这按预期工作,因为实际上来自两个 jsf 实现所共有的原始 Facelets 代码。众所周知,像 Google 应用程序引擎 (GAE) 这样的环境不允许获取文件的上次修改时间,但我不认为这是您的情况。
Look on MyFaces Web Config Params
javax.faces.FACELETS_REFRESH_PERIOD is the standard param name.
This param is used on development time for rebuild the view, so you can change your page and check your changes on the fly. You don't need to set that on production. Try set it to -1 and that disables it. That works as expected, because in fact comes from original facelets code which is common to both jsf implementations. It is known that environments like Google Application Engine (GAE) does not allow get the file last-modified-time, but I don't believe that is your case.