Improved push conditions
This commit is contained in:
parent
85a26a5c5b
commit
81ffe05834
4
main.go
4
main.go
@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/aerogo/session-store-nano"
|
||||
"github.com/animenotifier/arn"
|
||||
@ -68,7 +70,7 @@ func configure(app *aero.Application) *aero.Application {
|
||||
|
||||
// Do not use HTTP/2 push on service worker requests
|
||||
app.AddPushCondition(func(ctx *aero.Context) bool {
|
||||
return ctx.Request().Header().Get("X-Source") != "service-worker"
|
||||
return !strings.Contains(ctx.Request().Header().Get("Referer"), "/service-worker")
|
||||
})
|
||||
|
||||
// Specify test routes
|
||||
|
@ -211,14 +211,8 @@ class MyServiceWorker {
|
||||
prefetchFullPage(url: string) {
|
||||
let fullPage = new Request(url.replace("/_/", "/"))
|
||||
|
||||
// Disable HTTP/2 push responses
|
||||
let headers = new Headers({
|
||||
"X-Source": "service-worker"
|
||||
})
|
||||
|
||||
let fullPageRefresh = fetch(fullPage, {
|
||||
credentials: "same-origin",
|
||||
headers
|
||||
credentials: "same-origin"
|
||||
}).then(response => {
|
||||
// Save the new version of the resource in the cache
|
||||
let cacheRefresh = caches.open(this.cache.version).then(cache => {
|
||||
|
Loading…
Reference in New Issue
Block a user