DEV Community

Discussion on: Do you prefer subdomains or subdirectories?

Collapse
 
qm3ster profile image
Mihail Malo • Edited

subdirectory (path), because:

  • Maintain HTTP2/HTTP3 connection across the wild internet when going from one to the other (even if they all just go to a load balancing router)
  • Less DNS lookups
  • Shared cookies/permissions/localStorage (global darkmode, global signin)
  • Can share cached items, like brand static CSS/imagery/icons, including service worker
  • SEO, different aspects boost each other's relevance

subdomains should only be used when you explicitly need to break one of these, such as:

  • security, having a more locked-down (headers, deployment access, auditing) authentication/payment service
  • directing images/downloads to a third party cdn or service like cloudinary/imgix. (infrastructure simplification is tremendous)
  • ...I can't think of another one at the moment, things like "users of feature x and feature y don't overlap" and "I have a gorillion developers in independent teams working on independent features" has many solutions, from application routers to microfrontends.
  • short urls like youtu.be/<id> and t.me/<id> are fun yay (and they usually can be statelessly redirected at edge, let alone have content themselves, so they don't participate in a lot of the drawbacks)
Collapse
 
madza profile image
Madza

Thanks for the input 🙏❤