mdvanes / mdworld-jackson

mdworld theme "Jackson"
https://mdvanes.github.io/mdworld-jackson
MIT License
0 stars 0 forks source link

404 redirect loop #23

Closed mdvanes closed 6 years ago

mdvanes commented 6 years ago

Load https://mdvanes.github.io/mdworld-simon/ sometimes gets in a 404 reload loop. Stop and go back and correctly loads: https://mdworld.nl/mdworld-simon/

Not tested if this also happens when directly opening https://mdworld.nl/mdworld-simon/

mdvanes commented 6 years ago

https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-offline uses https://github.com/GoogleChromeLabs/sw-precache

with default whitelist isPathWhitelisted(["^.*([^.]{5}|.html)$"], event.request.url)

so e.g. "https://mdworld.nl/mdworld-ingram/" is attempted to be retrieved from cache with the fallback url "https://mdworld.nl/offline-plugin-app-shell-fallback/index.html"

The 404 page can be either briefly seen, or it gets stuck in a loop. Instead, the cache should be skipped completely, i.e. "https://mdworld.nl/mdworld-ingram/" should not match the whitelist regexp.

mdvanes commented 6 years ago

https://regex101.com/r/BA2s0Y/1

^.*([^.]{5}|.html)$ matches https://mdworld.nl/mdworld-ingram/ and does not match https://mdworld.nl/mdworld-ingram/foo.js (as intended by the default config).

This should work: (?=^.*([^.]{5}|.html)$)(?=^(?!https:\/\/mdworld\.nl\/mdworld-ingram\/).*$) adding more exceptions (AND NOT) like: (?=^.*([^.]{5}|.html)$)(?=^(?!https:\/\/mdworld\.nl\/mdworld-ingram\/).*$)(?=^(?!https:\/\/mdworld\.nl\/mdworld-simon\/).*$)