blob: ce4289b5347e9c802d76847db0a6bc0fd7fbf7f3 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>The L1 Session Cache</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><meta name="keywords" content="jetty, servlet, servlet-api, cometd, http, websocket, eclipse, maven, java, server, software"><link rel="home" href="index.html" title="Jetty"><link rel="up" href="session-management.html" title="Chapter&nbsp;10.&nbsp;Session Management"><link rel="prev" href="session-configuration-housekeeper.html" title="The SessionIdManager and the Housekeeper"><link rel="next" href="configuring-sessions-memory.html" title="Non-Persistent Sessions"><link xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" rel="shortcut icon" href="images/favicon.ico"><link rel="stylesheet" href="css/highlighter/foundation.css"><script src="js/highlight.pack.js"></script><script>
hljs.initHighlightingOnLoad();
</script><link type="text/css" rel="stylesheet" href="css/font-awesome/font-awesome.min.css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><tr><td style="width: 25%"><a href="http://www.eclipse.org/jetty"><img src="images/jetty-header-logo.png" alt="Jetty Logo"></a><br><span style="font-size: small">
Version: 9.4.28-SNAPSHOT</span></td><td style="width: 50%"></td></tr></table><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">The L1 Session Cache</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="session-configuration-housekeeper.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;10.&nbsp;Session Management<br><a accesskey="p" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="configuring-sessions-memory.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr></table><hr></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="jetty-callout"><h5 class="callout"><a href="http://www.webtide.com/">Contact the core Jetty developers at
<span class="website">www.webtide.com</span></a></h5><p>
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ...
scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="session-configuration-sessioncache"></a>The L1 Session Cache</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="session-configuration-sessioncache.html#_the_defaultsessioncache">The DefaultSessionCache</a></span></dt><dt><span class="section"><a href="session-configuration-sessioncache.html#_the_nullsessioncache">The NullSessionCache</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_the_defaultsessioncache"></a>The DefaultSessionCache</h3></div></div></div><p>In the absence of any explicit configuration, Jetty will instantiate an instance of the <code class="literal">DefaultSessionCache</code> per context.
If you wish to change any of the default values, you need to enable the <code class="literal">session-cache-hash</code> <a class="link" href="startup-modules.html" title="Managing Startup Modules">module</a>.</p><p>Once the <code class="literal">session-cache-hash</code> module has been enabled, you can view a list of all the configurable values by opening <code class="literal">start.d/session-cache-hash.ini</code>:</p><div class="screenexample"><pre class="screen">--module=session-cache-hash
#jetty.session.evictionPolicy=-1
#jetty.session.saveOnInactiveEvict=false
#jetty.session.saveOnCreate=false
#jetty.session.removeUnloadableSessions=false
#jetty.session.flushOnResponseCommit=false</pre></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">jetty.session.evictionPolicy</span></dt><dd><p class="simpara">Integer.
Controls whether session objects that are held in memory are subject to eviction from the memory cache.
Evicting sessions can reduce the memory footprint of the cache.
Eviction is usually used in conjunction with a <code class="literal">SessionDataStore</code> that persists sessions.
Values are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">-1 : sessions are never evicted from the cache</li><li class="listitem">0 : sessions are evicted from the cache as soon as the last active request for it finishes</li><li class="listitem">&gt;= 1 : any positive number is the time in seconds after which a session that is in the cache but has not experienced any activity will be evicted</li></ul></div></dd></dl></div><div class="blockquote"><blockquote class="blockquote"><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><i class="fa fa-asterisk" aria-hidden="true"></i> Note</h3><p>If you are not using a <code class="literal">SessionDataStore</code> that persists sessions, be aware that evicted sessions will be lost.</p></div></blockquote></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">jetty.session.saveOnInactiveEvict</span></dt><dd>Boolean, default <code class="literal">false</code>.
Controls whether a session will be saved to the <code class="literal">SessionDataStore</code> just prior to its eviction.</dd><dt><span class="term">jetty.session.saveOnCreate</span></dt><dd>Boolean, default <code class="literal">false</code>.
Controls whether a session that is newly created will be immediately saved to the <code class="literal">SessionDataStore</code> or lazily saved as the last request for the session exits.</dd><dt><span class="term">jetty.session.removeUnloadableSessions</span></dt><dd>Boolean, default <code class="literal">false</code>.
Controls whether a session that cannot be restored - for example because it is corrupted - from the <code class="literal">SessionDataStore</code> is deleted by the <code class="literal">SessionDataStore</code>.</dd><dt><span class="term">jetty.session.flushOnResponseCommit</span></dt><dd>Boolean, default <code class="literal">false</code>.
If true, if a session is "dirty" - ie its attributes have changed - it will be written to the backing store as the response is about to commit.
This ensures that all subsequent requests whether to the same or different node will see the updated session data.
If false, a dirty session will only be written to the backing store when the last simultaneous request for it leaves the session.</dd></dl></div><p>For more general information on the uses of these configuration properties, see <a class="link" href="sessions-details.html" title="Session Components">Session Components</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_the_nullsessioncache"></a>The NullSessionCache</h3></div></div></div><p>The <code class="literal">NullSessionCache</code> is a trivial implementation of the <code class="literal">SessionCache</code> that does not cache any session information.
You may need to use it if your clustering setup does not have a sticky load balancer, or if you want absolutely minimal support for sessions.
If you use this in conjunction with the <code class="literal">NullSessionDataStore</code>, then sessions will neither be retained in memory nor persisted.</p><p>To enable the <code class="literal">NullSessionCache</code>, enable the <code class="literal">sesssion-cache-null</code> <a class="link" href="startup-modules.html" title="Managing Startup Modules">module</a>.
Configuration options are:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">jetty.session.saveOnCreate</span></dt><dd>Boolean, default <code class="literal">false</code>.
Controls whether a session that is newly created will be immediately saved to the <code class="literal">SessionDataStore</code> or lazily saved as the last request for the session exits.</dd><dt><span class="term">jetty.session.removeUnloadableSessions</span></dt><dd>Boolean, default <code class="literal">false</code>.
Controls whether a session that cannot be restored - for example because it is corrupted - from the <code class="literal">SessionDataStore</code> is deleted by the <code class="literal">SessionDataStore</code>.</dd><dt><span class="term">jetty.session.flushOnResponseCommit</span></dt><dd>Boolean, default <code class="literal">false</code>.
If true, if a session is "dirty" - ie its attributes have changed - it will be written to the backing store as the response is about to commit.
This ensures that all subsequent requests whether to the same or different node will see the updated session data.
If false, a dirty session will only be written to the backing store when the last simultaneous request for it leaves the session.</dd></dl></div><p>For more general information on the uses of these configuration properties, see <a class="link" href="sessions-details.html" title="Session Components">Session Components</a>.</p></div></div><script type="text/javascript">
SyntaxHighlighter.all()
</script><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="session-configuration-housekeeper.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="session-management.html"><i class="fa fa-chevron-up" aria-hidden="true"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="configuring-sessions-memory.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr><tr><td width="40%" align="left" valign="top">The SessionIdManager and the Housekeeper&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></td><td width="40%" align="right" valign="top">&nbsp;Non-Persistent Sessions</td></tr></table></div><p xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><div class="jetty-callout">
See an error or something missing?
<span class="callout"><a href="http://github.com/eclipse/jetty.project">Contribute to this documentation at
<span class="website"><i class="fa fa-github" aria-hidden="true"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2020-03-10)</i></span></div></p></body></html>