public class CacheEnforcementVisitor extends ResourceMutateVisitor
resourceTags and
reserves html tag nodes whose uri attributes are either not in cache, or are
in cache, but the response in cache is either stale or an error response. In
all the above mentioned cases except for the error case, we trigger a
background fetch for the resource. This visitor should be used by a rewriter
in conjuction with other visitors which depend on the uri of the html node
being in cache.
Note that in order to use the CacheEnforcementVisitor effectively, the
shindig property shindig.cache.http.strict-no-cache-resource.max-age should
be set to a positive value, so that strict no-cache resources are stored in
cache with this ttl, and unnecessary fetches are not triggered each time for
such resources.ResourceMutateVisitor.TagsDomWalker.Visitor.VisitStatus| Modifier and Type | Field and Description |
|---|---|
static String |
CACHE_ENFORCEMENT_FETCH_PARAM |
featureConfig, resourceTags| Constructor and Description |
|---|
CacheEnforcementVisitor(ContentRewriterFeature.Config featureConfig,
Executor executor,
HttpCache cache,
RequestPipeline requestPipeline,
ResourceMutateVisitor.Tags... resourceTags)
Constructs the cache enforcement visitor.
|
| Modifier and Type | Method and Description |
|---|---|
protected HttpRequest |
createNewHttpRequest(Gadget gadget,
String uriStr)
Constructs a new HttpRequest in the context of the gadget.
|
protected DomWalker.Visitor.VisitStatus |
handleResponseInCache(HttpRequest request,
HttpResponse response)
The action to be performed if the response is in cache.
|
protected DomWalker.Visitor.VisitStatus |
handleResponseNotInCache(HttpRequest request)
The action to be performed if the response is not in cache.
|
protected Collection<Pair<Node,Uri>> |
mutateUris(Gadget gadget,
Collection<Node> nodes) |
protected void |
triggerFetch(HttpRequest request)
Triggers a background fetch for a resource.
|
DomWalker.Visitor.VisitStatus |
visit(Gadget gadget,
Node node)
Visit a particular Node in the DOM.
|
revisitpublic static final String CACHE_ENFORCEMENT_FETCH_PARAM
public CacheEnforcementVisitor(ContentRewriterFeature.Config featureConfig, Executor executor, HttpCache cache, RequestPipeline requestPipeline, ResourceMutateVisitor.Tags... resourceTags)
protected HttpRequest createNewHttpRequest(Gadget gadget, String uriStr)
public DomWalker.Visitor.VisitStatus visit(Gadget gadget, Node node) throws RewritingException
ResourceMutateVisitorvisit in interface DomWalker.Visitorvisit in class ResourceMutateVisitorgadget - Context for the request.node - Node being visited.VisitStatusRewritingExceptionprotected DomWalker.Visitor.VisitStatus handleResponseInCache(HttpRequest request, HttpResponse response)
request - HttpRequest to fetch the resource of the node.response - The HttpResponse retrieved from cache.protected DomWalker.Visitor.VisitStatus handleResponseNotInCache(HttpRequest request)
request - HttpRequest to fetch the resource of the node.protected void triggerFetch(HttpRequest request)
request - HttpRequest to fetch the resource of the node.protected Collection<Pair<Node,Uri>> mutateUris(Gadget gadget, Collection<Node> nodes)
mutateUris in class ResourceMutateVisitorCopyright © 2007-2014 The Apache Software Foundation. All Rights Reserved.