title: configure jetty 9.3.0 embedded (programmatically) with caching
body: <p>I can't seem to get my jetty to work with caching.
  I have a jetty server that will display html only.
  I have JavaScripts in there and a lot of images which I don't want to load every time. For example my application needs to switch in 10 seconds between 3 pages. Loading jQuery three times is time consuming and loading the logo picture and all that takes even longer. That's why I want to enable Caching.</p>
  <p>This is what I got:</p>
  <pre><code>server = new Server(); //new Jetty Server
  //setting up a ssl connection
  try
  {
      SslContextFactory cf = new SslContextFactory();
      cf.setKeyStorePath(keystore);
      cf.setKeyStorePassword(&quot;password&quot;);
      
      HttpConfiguration config = new HttpConfiguration();
      config.addCustomizer(new SecureRequestCustomizer());
      config.setSecureScheme(&quot;https&quot;);
      config.setSecurePort(8443);
      
      HttpConfiguration sslConfiguration = new HttpConfiguration(config);
      sslConfiguration.addCustomizer(new SecureRequestCustomizer());
      
      httpConnector = new ServerConnector(server);
      httpConnector.addConnectionFactory(new HttpConnectionFactory(config));
      httpConnector.setPort(suggestHttpPort());
      httpConnector.setName(&quot;unsecured&quot;);
      sslConnector = new ServerConnector(server, 
              new SslConnectionFactory(cf, HttpVersion.HTTP_1_1.toString()), 
              new HttpConnectionFactory(sslConfiguration));
      sslConnector.setPort(suggestHttpSSLPort());
      sslConnector.setName(&quot;secured&quot;);
      
      server.setConnectors(new Connector[] { httpConnector, sslConnector });  
  }
  catch (Exception e)
  {
      log.error(&quot;setting up Jetty failed&quot;, e);
  }
  // This is where i want to enable caching, at least that is what i have figuged out so far but its not working
  DefaultServlet defaultServlet = new DefaultServlet();
  ServletHolder holder = new ServletHolder(defaultServlet);
  holder.setInitParameter(&quot;cacheControl&quot;, &quot;max-age=120, public&quot;);
  ServletContextHandler bb = new ServletContextHandler();
  bb.addServlet(holder, &quot;/&quot;);
  server.setHandler(bb);
  server.start();
  </code></pre>
  <p>What am I doing wrong? I want to enable caching for everything...</p>