File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,12 @@ self.addEventListener('fetch', event => {
9595 // Skip some of cross-origin requests, like those for Google Analytics.
9696 if ( HOSTNAME_WHITELIST . indexOf ( new URL ( event . request . url ) . hostname ) > - 1 ) {
9797
98+ // Redirect in SW manually fixed github pages 404s on repo?blah
99+ if ( shouldRedirect ( event . request ) ) {
100+ event . respondWith ( Response . redirect ( `${ event . request . url } /` ) )
101+ return ;
102+ }
103+
98104 // Stale-while-revalidate
99105 // similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale
100106 // Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1
@@ -103,17 +109,6 @@ self.addEventListener('fetch', event => {
103109 const fetched = fetch ( fixedUrl , { cache : "no-store" } ) ;
104110 const fetchedCopy = fetched . then ( resp => resp . clone ( ) ) ;
105111
106- // Redirect in SW manually fixed github pages 404s on repo?blah
107- if ( shouldRedirect ( event . request ) ) {
108- event . respondWith (
109- new Response ( null , {
110- "status" : 301 ,
111- "headers" : { "location" : `${ event . request . url } /` }
112- } )
113- )
114- return ;
115- }
116-
117112 // Call respondWith() with whatever we get first.
118113 // If the fetch fails (e.g disconnected), wait for the cache.
119114 // If there’s nothing in cache, wait for the fetch.
You can’t perform that action at this time.
0 commit comments