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 is used
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 setReferrerPushPeriod(int)
has to be set. If the referrerPushPeriod for a main resource has elapsed, 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 setMaxAssociatedResources(int)
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() |
Modifier and Type | Method and Description |
---|---|
Set<String> |
apply(Stream stream,
Fields requestHeaders,
Fields responseHeaders)
Applies the SPDY push logic for the primary resource.
|
Set<Pattern> |
getAllowedPushOrigins() |
int |
getMaxAssociatedResources() |
Set<String> |
getPushContentTypes() |
Set<Pattern> |
getPushRegexps() |
int |
getReferrerPushPeriod() |
Set<Pattern> |
getUserAgentBlacklist() |
boolean |
isUserAgentBlacklisted(Fields headers) |
void |
setAllowedPushOrigins(List<String> allowedPushOrigins) |
void |
setMaxAssociatedResources(int maxAssociatedResources) |
void |
setPushContentTypes(List<String> pushContentTypes) |
void |
setPushRegexps(List<String> pushRegexps) |
void |
setReferrerPushPeriod(int referrerPushPeriod) |
void |
setUserAgentBlacklist(List<String> userAgentPatterns) |
public void setMaxAssociatedResources(int maxAssociatedResources)
public void setReferrerPushPeriod(int referrerPushPeriod)
public int getMaxAssociatedResources()
public int getReferrerPushPeriod()
public Set<String> apply(Stream stream, Fields requestHeaders, Fields responseHeaders)
PushStrategy
Applies the SPDY push logic for the primary resource.
apply
in interface PushStrategy
stream
- the primary resource streamrequestHeaders
- the primary resource request headersresponseHeaders
- the primary resource response headerspublic boolean isUserAgentBlacklisted(Fields headers)
Copyright © 1995-2015 Webtide. All Rights Reserved.