Restricte route by user role, possibly a middleware?
And given that if they're loading a protected route they shouldn't have access to anyway they're not behaving, does it really matter if they get a slight FOUC?
@Tommypop seems like begit doesn't actually try to verify the cached file in any way, then crashes if it was corrupted (seems like mine was unexpectedly truncated)