Hosted by
Web created with:
|
Intro
How it works
ServletSpeedster is meant to handle the requests
that your servlet/jsp makes to get it's cacheable subparts.
While non cacheable content should be called directly,
the cacheable output should be requested from ServletSpeedster.
Each time you ask for a cacheable subpart of a page from ServletSpeedster
it looks up if the cached version is up to date and servers either
a new output(if cache is invalid) or the cached output (if the cache is valid).
The following drawings will explain the idea.
The quality of the images is not quite the top but i tried
to size them down as much as possible to make the page load quickly.
Part your servlet into reasonable components
See how the cache really works
Consider your choice of caching rule
Try to imagine your site as parts before writing anything
If you create a EJB based (web) application, this is the idea there.
How does the necessary code look
If you have already splitted up your jsp/servlet page the original
codeblock there should probably look like this
<jsp:include page="/somepath"/>
or this
RequestDispatcher dispatcher = request.getRequestDispacher("/somepath");
dispatcher.include(request,response);
All you need to do now is to change the "somepath" into a path
that is bound to the SpeedsterServlet that is ordered to cache
the specific part of the page.
A good habbit could be that
all the cached subpages could be hidden behind a path /cached/
so you can deny access to them from outside of the servlet engine.
What can included subpages do ?
Subpages Can
- Create output
- Call whatever ejb or other calls you need to make*
(*Cached subpages only create output, so they obviously can't make
any calls unless they are really called out by the SpeedsterServlet
for creating a new cached item.)
Subpages Can Not
- Set their own headers
- Send redirect calls*
(*Can anyone tell me why they would like to create ANY output while still
considering if the client should be redirected ?)
|