public class ReferrerPushStrategy extends Object implements PushStrategy
A SPDY push strategy that auto-populates push metadata based on referrer URLs.
A typical request for a main resource such as index.html is immediately followed by a number of requests for associated resources. Associated resource requests will have a Referer HTTP header that points to index.html, which we use to link the associated resource to the main resource.
However, also following a hyperlink generates a HTTP request with a Referer
HTTP header that points to index.html; therefore a proper value for getReferrerPushPeriod()
has to be set. If the referrerPushPeriod for a main resource has been passed, no more
associated resources will be added for that main resource.
This class distinguishes associated main resources by their URL path suffix and content type. CSS stylesheets, images and JavaScript files have recognizable URL path suffixes that are classified as associated resources. The suffix regexs can be configured by constructor argument
When CSS stylesheets refer to images, the CSS image request will have the CSS stylesheet as referrer. This implementation will push also the CSS image.
The push metadata built by this implementation is limited by the number of pages
of the application itself, and by the
max associated resources
parameter.
This parameter limits the number of associated resources per each main resource, so
that if a main resource has hundreds of associated resources, only up to the number
specified by this parameter will be pushed.
PushStrategy.None
Constructor and Description |
---|
ReferrerPushStrategy() |
ReferrerPushStrategy(List<String> pushRegexps) |
ReferrerPushStrategy(List<String> pushRegexps,
List<String> pushContentTypes) |
ReferrerPushStrategy(List<String> pushRegexps,
List<String> pushContentTypes,
List<String> allowedPushOrigins) |
Modifier and Type | Method and Description |
---|---|
Set<String> |
apply(Stream stream,
Headers requestHeaders,
Headers responseHeaders) |
int |
getMaxAssociatedResources() |
int |
getReferrerPushPeriod() |
void |
setMaxAssociatedResources(int maxAssociatedResources) |
void |
setReferrerPushPeriod(int referrerPushPeriod) |
public ReferrerPushStrategy()
public ReferrerPushStrategy(List<String> pushRegexps, List<String> pushContentTypes)
public int getMaxAssociatedResources()
public void setMaxAssociatedResources(int maxAssociatedResources)
public int getReferrerPushPeriod()
public void setReferrerPushPeriod(int referrerPushPeriod)
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.