javascript - Can you write a Firebase Function that only get triggered by GoogleBot -
so have created single page web app using firebase each page has content dynamically loaded firebase database.
search engines however, see blank pages , not dynamic content. created firebase function pre-render each page seo purposes, has worked great.
the issue has majorly affected user experience there delay function being run, followed fouc when dynamic content loaded other js.
is possible trigger pre-rendering function googlebot (and other know crawlers/bots) allowing normal website experience users , pre-rendered html page bots.
thanks
edit:
exports.helloworld = functions.https.onrequest((request, response) => { // console.log(request.useragent) }
the user agent expected is:
"mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, gecko) chrome/59.0.3071.115 safari/537.36"
however has snippet appended it:
"mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, gecko) chrome/59.0.3071.115 safari/537.36 appengine-google; (+http://code.google.com/appengine; appid: s~gcf-http-proxy)"
i have tried several plugins detect bots, each of these report bot due appengine-google
cloud functions firebase uses express middleware http triggers. it's quite possible detect crawlers, shown here detect social bots in node express , how detect web crawlers seo, using express?.
but wonder if you're steering in right direction there.
while pre-rendering may take more time serving raw content, time should compensated rendering meaningful rendition straight away. there way great article server-side rendering cloud functions , express recently.
in addition (unless data dynamic) of users should hitting cached version of html. see david easts talk dynamic http @ i/o, explanation of setting cache headers in cloud functions.
Comments
Post a Comment