Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Conditionally use fastbootMiddleware #99

Open
betocantu93 opened this issue Mar 6, 2019 · 2 comments
Open

Feature: Conditionally use fastbootMiddleware #99

betocantu93 opened this issue Mar 6, 2019 · 2 comments

Comments

@betocantu93
Copy link

betocantu93 commented Mar 6, 2019

In most of the use cases that I use Fastboot, its mainly because of the SEO and OG tags (consumed by bots), not for the actual render of something to the end user, while its nice and rehydratation make it even better, sometimes I prefer the instant loading feel (getting fastboot off of the crital path) with an appshell for loading screen, this can be accomplish by using fastboot middleware conditionally from reading user-agent string to detect if its a bot or a human. I got it working by adding this middleware in Worker.js for ExpressServer, since the code always expects a middleware, I condiotionally run the fastbootmiddleware or just an empty one, using express-conditional-middleware

app.use(
  conditional(
   (req, res, next) => { return this.isBot(req.get('user-agent')) }, 
   fastbootMiddleware, 
   (req, res, next) => { next() }
  ) 
)

I think this feature could be exposed as config as boolean, please let me know your thoughts

@CvX
Copy link

CvX commented Apr 15, 2019

That does sound great, but I'm wondering if Google or other search bots wouldn't penalize such behavior. I remember that Google was detecting attempts of gaming the system, i.e. pages that were returning different content (usually injected with extra keywords) if user agent matched know crawlers.

In theory this case is different, because in the end (after everything is rendered) the output is the same. Yet, the raw html that is returned from the server is vastly different.

@betocantu93
Copy link
Author

Interesting, I'll investigate this further

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants