I have React web app. It's a single page app, so there's basically an "empty" HTML file with a JS bundle that does it all.
But to improve SEO capabilities, I'm doing SSR for robot crawlers on my server. I also differentiate "desktop" crawlers from "mobile" crawlers and render different layouts for each one of them.
I differentiate users and robots by their User-Agent
string.
So these are the possibilities:
REGULAR USER => GETS "EMPTY" HTML + JS BUNDLE
ROBOT DESKTOP => GETS RENDERED HTML WITH DESKTOP LAYOUT
ROBOT MOBILE => GETS RENDERED HTML WITH MOBILE LAYOUT
I'm pretty sure that I need to include a res.set("Vary","User-Agent");
header.
But should I add it to all responses or just to the SSR responses that are served to the robots?