13

有没有人建议为 JSP 设置最佳缓冲区大小?您可以使用以下页面指令来设置 JSP 中的缓冲区大小

    <%@page buffer="xxxkb" autoFlush="true" %>

我的问题如下

  1. 我的理解是,您使用的缓冲区大小越小,客户端浏览器的性能就越好。我的假设正确吗?如果您不这么认为,请解释

  2. 最佳缓冲区大小应该是多少

  3. 有没有办法知道默认缓冲区大小是多少?

  4. 将 autoflush 设置为 true 应在达到最大大小后刷新缓冲区。如果将其设置为 false,则由您决定何时刷新

4

1 回答 1

15

1.我的理解是,您使用的缓冲区大小越小,客户端浏览器的性能越好。我的假设正确吗?如果您不这么认为,请解释

答:是的,实际上不是在性能方面。但在渲染内容方面。因为客户端会以更快的速度获取数据。缓冲区大小应大于或等于底层套接字缓冲区大小。否则,尽管当达到缓冲区大小时 jsp 会刷新,但实际上不会将其写入客户端。

2.最佳缓冲区大小应该是多少

答:正如我上面所说,它应该大于或等于底层套接字缓冲区大小。最佳尺寸还取决于您的应用。它应该是这样一个值,一旦达到缓冲区大小,响应将被提交,您不能再进行任何操作,从而导致添加响应头。

3.有没有办法知道默认缓冲区大小是多少?

Answer : Yes , by using JspWriter class. JspWriter has a getter getBufferSize() which gives you the buffer size. The JspWriter can be obtained using pageContext.getOut().

4.Setting autoflush to true should flush the buffer once the max size reached. If you set it to false, its upto you to decide when to flush

Answer: If set to true, it will flush when the max buffer size is reached. If set to false, it will throw an exception

于 2012-06-03T08:23:33.857 回答