Hi,
I'm starting to work with memcache and app engine (java). I have a page where I can cache results fetched from the datastore. Example:
// index.jsp
<%
List<Horse> horses = datastore.getHorses(PMF.get());
for (Horse it : horses) {
%>
<div><%= it.getName() %></div>
<%
}
%>
I can put the horse list into memcache, but would it make more sense to just cache the entire page contents? I mean next time the user wants to load this page, just spit back the entire html content stored in the cache as a string? Wondering if that's possible or a good practice. I'm not sure how I would do this anyway, since I would need to create one massive string of all the html content, then print() it in the jsp, and also store it in memcache, something like:
// index.jsp
<%
List<Horse> horses = datastore.getHorses(PMF.get());
StringBuilder sb = new StringBuilder();
for (Horse it : horses) {
sb.append("<div>");
sb.append(it.getName());
sb.append("</div>");
}
// Render contents.
<%= sb.toString() %>
// Also can store it in memcache for future requests.
memCache.put("test/index.jsp", sb.toString());
%>
Thanks