<commit_before>package com.github.onsdigital.api;

import java.io.IOException;
import java.io.Reader;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;

import com.github.davidcarboni.ResourceUtils;
import com.github.davidcarboni.restolino.framework.Home;
import com.github.onsdigital.search.ElasticSearchServer;

public class HomePage implements Home {

	@Override
	public Object get(HttpServletRequest request, HttpServletResponse response) throws IOException {

		// TODO: run this on server startup:
		ElasticSearchServer.startEmbeddedServer();

		// Ensures ResourceUtils gets the right classloader when running
		// reloadable in development:
		ResourceUtils.classLoaderClass = HomePage.class;

		// Serve up the angular template
		response.setCharacterEncoding("UTF8");
		response.setContentType("text/html");
		try (Reader index = ResourceUtils.getReader("/files/index.html")) {
			IOUtils.copy(index, response.getWriter());
		}

		// response.sendRedirect("/home");

		return null;
	}
<commit_msg>Added 5-minute caching for the Angular app page.<commit_after>package com.github.onsdigital.api;

import java.io.IOException;
import java.io.Reader;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;

import com.github.davidcarboni.ResourceUtils;
import com.github.davidcarboni.restolino.framework.Home;
import com.github.onsdigital.search.ElasticSearchServer;

public class HomePage implements Home {

	@Override
	public Object get(HttpServletRequest request, HttpServletResponse response) throws IOException {

		// TODO: run this on server startup:
		ElasticSearchServer.startEmbeddedServer();

		// Ensures ResourceUtils gets the right classloader when running
		// reloadable in development:
		ResourceUtils.classLoaderClass = HomePage.class;

		// Cache for five minutes - helps if someone refreshes the page:
		response.setHeader("cache-control", "public, max-age=300");
		response.setCharacterEncoding("UTF8");
		response.setContentType("text/html");
		// Serve up the angular template
		try (Reader index = ResourceUtils.getReader("/files/index.html")) {
			IOUtils.copy(index, response.getWriter());
		}

		// response.sendRedirect("/home");

		return null;
	}

{'fraction_non_alphanumeric': 0.10290350128095645, 'fraction_numerical': 0.0025619128949615714, 'mean_word_length': 5.117493472584856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2009278', 'n_tokens_mistral': 707, 'n_tokens_neox': 657, 'n_words': 156}