Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2012-07-06 14:55:45 +0000
committerThomas Becker2012-07-06 15:33:52 +0000
commit77c673c89bbe73d3e8086b8af81303d749c2d447 (patch)
tree0560981aa550b54d957ea1d60dbd3c72cabc97fb
parent652fcc35525a9060d694b296984d3a60653ceb1c (diff)
downloadorg.eclipse.jetty.project-77c673c89bbe73d3e8086b8af81303d749c2d447.tar.gz
org.eclipse.jetty.project-77c673c89bbe73d3e8086b8af81303d749c2d447.tar.xz
org.eclipse.jetty.project-77c673c89bbe73d3e8086b8af81303d749c2d447.zip
spdy: push referrer call period starts when first resource is added. Before it started when main resource was created
-rw-r--r--jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java
index 6070f1c1dc..0d7857f931 100644
--- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java
+++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ReferrerPushStrategy.java
@@ -24,6 +24,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
import org.eclipse.jetty.spdy.api.Headers;
@@ -213,17 +214,23 @@ public class ReferrerPushStrategy implements PushStrategy
private class MainResource
{
private final String name;
- private final long created = System.nanoTime();
private final Set<String> resources = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
+ private final AtomicLong firstResourceAdded = new AtomicLong(-1);
- MainResource(String name)
+ private MainResource(String name)
{
this.name = name;
}
public boolean addResource(String url, String origin, String referrer)
{
- long delay = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - created);
+ // We start the push period here and not when initializing the main resource, because a browser with a
+ // prefilled cache won't request the subresources. If the browser with warmed up cache now hits the main
+ // resource after a server restart, the push period shouldn't start until the first subresource is
+ // being requested.
+ firstResourceAdded.compareAndSet(-1, System.nanoTime());
+
+ long delay = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - firstResourceAdded.get());
if (!referrer.startsWith(origin) && !isPushOriginAllowed(origin))
{
logger.debug("Skipped store of push metadata {} for {}: Origin: {} doesn't match or origin not allowed",

Back to the top