Skip to content

Commit c1b5676

Browse files
committed
mention setHistoryPageCacheLimit(0) / setHistorySizeLimit(0) in the faq
1 parent c8595eb commit c1b5676

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/site/fml/faq.fml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ INFO: Redirect requested but followRedirects is disabled</source>
302302
or implement your own CSSErrorHandler.
303303
</p>
304304
<source><![CDATA[
305-
306305
try (WebClient webClient = new WebClient(browserVersion)) {
307306
webClient.setCssErrorHandler(new SilentCssErrorHandler());
308307
....
@@ -336,11 +335,23 @@ INFO: Redirect requested but followRedirects is disabled</source>
336335
</question>
337336
<answer>
338337
<p>
339-
Make sure (a) that you are using the latest version of HtmlUnit, and
340-
(b) that you are calling WebClient.close()
341-
(or use <a href="http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html">try-with-resources</a>)
342-
when you are finished with your WebClient instance.
338+
Make sure
339+
<ol>
340+
<li>that you are using the latest version of HtmlUnit, and
341+
<li>that you are calling WebClient.close() (or use <a href="http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html">try-with-resources</a>) when you are finished with your WebClient instance.
342+
<ol>
343+
</p>
344+
<p>
345+
Like real browsers HtmlUnit maintains a history for every window to be able to support the back() action. If you don't need this
346+
you can disable the history by
343347
</p>
348+
<source><![CDATA[
349+
try (WebClient webClient = new WebClient(browserVersion)) {
350+
webClient.getOptions().setHistoryPageCacheLimit(0);
351+
webClient.getOptions().setHistorySizeLimit(0);
352+
....
353+
}
354+
]]></source>
344355
</answer>
345356
</faq>
346357

0 commit comments

Comments
 (0)