Fixes for caching issue with PageRenderer freemarker template processing

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6905 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-10-03 09:30:14 +00:00
parent 4403c1d083
commit b26870416a
3 changed files with 17 additions and 1 deletions

View File

@@ -174,6 +174,8 @@ public class PageRendererServlet extends WebScriptServlet
} }
} }
setNoCacheHeaders(res);
try try
{ {
// lookup template path from page config in website AVM store // lookup template path from page config in website AVM store
@@ -447,6 +449,15 @@ public class PageRendererServlet extends WebScriptServlet
(page != null ? page + '/' : "") + "page-definition.xml"; (page != null ? page + '/' : "") + "page-definition.xml";
} }
/**
* Apply the headers required to disallow caching of the response in the browser
*/
private static void setNoCacheHeaders(HttpServletResponse res)
{
res.setHeader("Cache-Control", "no-cache");
res.setHeader("Pragma", "no-cache");
}
/** /**
* WebScript runtime for the PageRenderer servlet. * WebScript runtime for the PageRenderer servlet.
@@ -707,7 +718,7 @@ public class PageRendererServlet extends WebScriptServlet
public long getLastModified(Object templateSource) public long getLastModified(Object templateSource)
{ {
return last--; return last++;
} }
public Reader getReader(Object templateSource, String encoding) throws IOException public Reader getReader(Object templateSource, String encoding) throws IOException

View File

@@ -45,5 +45,6 @@ public class PageTemplateProcessor extends TemplateProcessor
public void initConfig() public void initConfig()
{ {
super.initConfig(); super.initConfig();
templateConfig.setTemplateUpdateDelay(0);
} }
} }

View File

@@ -94,6 +94,10 @@ public final class ScriptUrlMethod implements TemplateMethodModelEx
buf.append('&'); buf.append('&');
} }
} }
else
{
buf.append('?');
}
buf.append("guest=" + (req.isGuest() ? "true" : "")); buf.append("guest=" + (req.isGuest() ? "true" : ""));
if (req.getFormatStyle() == FormatStyle.argument) if (req.getFormatStyle() == FormatStyle.argument)
{ {