AnsweredAssumed Answered

Responding with a pre-processed webscript

Question asked by jvanderhoef on Feb 25, 2009
Latest reply on Feb 26, 2009 by jvanderhoef
My site currently depends on webscripts to build all its pages, what I'm trying to do is have each webscript save a static version of the page it generates into the alfresco respository, and successive requests for that webscript will respond with the static page it gernerated if it exists. This will save alot of processing time for my pages.

So far, I've only been able to have the webscript create a static file and populate it with the freemarker template, but don't know how to have it respond with the static file if it exists, also having issues with passing the freemarker template arguments.

Here is part of my code.


model.folders = getData(requestedFolder);

var htmlCheck = companyhome.childByNamePath("List.html");

if (htmlCheck != null)
   {
//need to return static page if it exists
   }
   else //process the webscript
   {
var template = companyhome.childByNamePath("Data Dictionary/Web Scripts/Testlist.get.html.ftl");
var document = companyhome.createFile("List.html");
var StaticResult = document.processTemplate(template, model.folders);
document.content = StaticResult;

}

I've been trying to get this to work for awhile, was wondering if anyone might have some ideas. Currently just trying to prove the proof of concept. Thanks

Outcomes