PageCompiler: add support for Cache-Control header

This commit is contained in:
Günter Obiltschnig
2018-08-08 11:04:31 +02:00
parent b7ac69ebc6
commit 148ba9ab72
2 changed files with 10 additions and 0 deletions

View File

@@ -311,6 +311,7 @@ void CodeWriter::writeResponse(std::ostream& ostr)
{
std::string contentType(_page.get("page.contentType", "text/html"));
std::string contentLang(_page.get("page.contentLanguage", ""));
std::string cacheControl(_page.get("page.cacheControl", ""));
bool buffered(_page.getBool("page.buffered", false));
bool chunked(_page.getBool("page.chunked", !buffered));
bool compressed(_page.getBool("page.compressed", false));
@@ -333,6 +334,10 @@ void CodeWriter::writeResponse(std::ostream& ostr)
ostr << "\tbool _compressResponse(request.hasToken(\"Accept-Encoding\", \"gzip\"));\n"
<< "\tif (_compressResponse) response.set(\"Content-Encoding\", \"gzip\");\n";
}
if (!cacheControl.empty())
{
ostr << "\tresponse.set(\"Cache-Control\", \"" << cacheControl << "\");\n";
}
ostr << "\n";
}